diff --git a/CHANGELOG.md b/CHANGELOG.md index ec85d368..441c6ca4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ # Unreleased ## New features +- **Breaking Change**: Add fct models `fct_student_iep`, `fct_idea_event`, and `fct_student_iep_disability`. These new models require adding the corresponding sources. ## Under the hood ## Fixes diff --git a/dbt_project.yml b/dbt_project.yml index 859ecfc0..b1b08a98 100644 --- a/dbt_project.yml +++ b/dbt_project.yml @@ -29,6 +29,9 @@ models: +enabled: "{{ var('edu:tpdm:enabled', False) }}" core_warehouse: +schema: wh + sedm_warehouse: + +schema: wh + +enabled: "{{ var('edu:sedm:enabled', False) }}" tpdm_warehouse: +schema: wh +enabled: "{{ var('edu:tpdm:enabled', False) }}" diff --git a/models/sedm_warehouse/fct_idea_event.sql b/models/sedm_warehouse/fct_idea_event.sql new file mode 100644 index 00000000..bf5b5b8d --- /dev/null +++ b/models/sedm_warehouse/fct_idea_event.sql @@ -0,0 +1,43 @@ +{{ + config( + post_hook=[ + "alter table {{ this }} alter column k_idea_event set not null", + "alter table {{ this }} alter column k_student set not null", + "alter table {{ this }} alter column k_student_xyear set not null", + "alter table {{ this }} add primary key (k_idea_event)", + "alter table {{ this }} add constraint fk_{{ this.name }}_student foreign key (k_student) references {{ ref('dim_student') }}", + ] + ) +}} + +with stage as ( + select * from {{ ref('stg_sedm__idea_events') }} +), + +dim_student as ( + select * from {{ ref('dim_student') }} +), + +formatted as ( + select + stage.k_idea_event, + dim_student.k_student, + dim_student.k_student_xyear, + stage.tenant_code, + stage.school_year, + stage.idea_event_id, + stage.ed_org_id, + stage.ed_org_type, + stage.idea_event, + stage.event_begin_date, + stage.event_end_date, + stage.event_narrative, + stage.event_reason, + stage.event_compliance + {{ edu_edfi_source.extract_extension(model_name='stg_sedm__idea_events', flatten=False) }} + from stage + inner join dim_student + on stage.k_student = dim_student.k_student +) + +select * from formatted diff --git a/models/sedm_warehouse/fct_idea_event.yml b/models/sedm_warehouse/fct_idea_event.yml new file mode 100644 index 00000000..0e6b99a3 --- /dev/null +++ b/models/sedm_warehouse/fct_idea_event.yml @@ -0,0 +1,60 @@ +version: 2 + +models: + - name: fct_idea_event + description: > + ##### Overview: + This fact table contains IDEA-related events for students (for example, meetings, + evaluations, or other documented IDEA processes), keyed to the warehouse student. + + ##### Primary Key: + `k_idea_event` -- There is one record per IDEA event association in the source data. + + config: + tags: ['sedm'] + enabled: "{{ var('edu:sedm:enabled', False) }}" + + constraints: + - type: primary_key + columns: [k_idea_event] + - type: foreign_key + name: fk__fct_idea_event__k_student + columns: [k_student] + to: ref('dim_student') + to_columns: [k_student] + + columns: + - name: k_idea_event + tests: + - unique + - not_null + - name: k_student + description: Defining key for the student in this school year. + - name: k_student_xyear + description: Defining key for the student, which is consistent across years. + - name: tenant_code + description: The tenant associated with the record. + - name: school_year + description: > + School year specified by Spring year. + e.g. the 2021-2022 year would be 2022. + - name: idea_event_id + description: A unique identifier for the event record as assigned by the provider of IEP services. + - name: ed_org_id + description: The identifier for the educational organization associated with the IDEA event. + - name: ed_org_type + description: > + The type of educational organization + e.g., School or LocalEducationAgency. + - name: idea_event + description: The specific legal step, procedure, or standard event milestone captured as part of IDEA compliance requirements. + - name: event_begin_date + description: The date when the IDEA related event started. + - name: event_end_date + description: The date when the IDEA related event concluded. + - name: event_narrative + description: Detailed and summary notes recorded during the event. + - name: event_reason + description: The reason why the IDEA event occurred. + - name: event_compliance + description: The type of compliance represented by this event. diff --git a/models/sedm_warehouse/fct_student_iep.sql b/models/sedm_warehouse/fct_student_iep.sql new file mode 100644 index 00000000..2d6b9111 --- /dev/null +++ b/models/sedm_warehouse/fct_student_iep.sql @@ -0,0 +1,48 @@ +{{ + config( + post_hook=[ + "alter table {{ this }} alter column k_student_iep set not null", + "alter table {{ this }} alter column k_student set not null", + "alter table {{ this }} alter column k_student_xyear set not null", + "alter table {{ this }} add primary key (k_student_iep)", + "alter table {{ this }} add constraint fk_{{ this.name }}_student foreign key (k_student) references {{ ref('dim_student') }}", + ] + ) +}} + +with stage as ( + select * from {{ ref('stg_sedm__student_ieps') }} +), + +dim_student as ( + select * from {{ ref('dim_student') }} +), + +formatted as ( + select + stage.k_student_iep, + dim_student.k_student, + dim_student.k_student_xyear, + stage.tenant_code, + stage.school_year, + stage.student_iep_association_id, + stage.ed_org_id, + stage.ed_org_type, + stage.iep_finalized_date, + stage.iep_begin_date, + stage.iep_end_date, + stage.iep_amended_date, + stage.iep_status, + stage.reason_exited, + stage.special_education_setting, + stage.is_medically_fragile, + stage.is_multiply_disabled, + stage.school_hours_per_week, + stage.special_education_hours_per_week + {{ edu_edfi_source.extract_extension(model_name='stg_sedm__student_ieps', flatten=False) }} + from stage + inner join dim_student + on stage.k_student = dim_student.k_student +) + +select * from formatted diff --git a/models/sedm_warehouse/fct_student_iep.yml b/models/sedm_warehouse/fct_student_iep.yml new file mode 100644 index 00000000..c95d3bb8 --- /dev/null +++ b/models/sedm_warehouse/fct_student_iep.yml @@ -0,0 +1,50 @@ +version: 2 + +models: + - name: fct_student_iep + description: > + ##### Overview: + This fact table contains student Individualized Education Program (IEP) records, + keyed to the warehouse student. + + ##### Primary Key: + `k_student_iep` -- There is one record per student IEP association in the source data. + + config: + tags: ['sedm'] + enabled: "{{ var('edu:sedm:enabled', False) }}" + + constraints: + - type: primary_key + columns: [k_student_iep] + - type: foreign_key + name: fk__fct_student_iep__k_student + columns: [k_student] + to: ref('dim_student') + to_columns: [k_student] + + columns: + - name: k_student_iep + tests: + - unique + - not_null + - name: k_student + description: Defining key for the student in this school year. + - name: k_student_xyear + description: Defining key for the student, which is consistent across years. + - name: tenant_code + - name: school_year + - name: student_iep_association_id + - name: ed_org_id + - name: ed_org_type + - name: iep_finalized_date + - name: iep_begin_date + - name: iep_end_date + - name: iep_amended_date + - name: iep_status + - name: reason_exited + - name: special_education_setting + - name: is_medically_fragile + - name: is_multiply_disabled + - name: school_hours_per_week + - name: special_education_hours_per_week diff --git a/models/sedm_warehouse/fct_student_iep_disability.sql b/models/sedm_warehouse/fct_student_iep_disability.sql new file mode 100644 index 00000000..22310ff5 --- /dev/null +++ b/models/sedm_warehouse/fct_student_iep_disability.sql @@ -0,0 +1,27 @@ +{{ + config( + post_hook=[ + "alter table {{ this }} add constraint fk_{{ this.name }}_student_iep foreign key (k_student_iep) references {{ ref('fct_student_iep') }}", + ] + ) +}} + +with disabilities as ( + select * from {{ ref('stg_sedm__student_iep_disability_collections') }} +), + +formatted as ( + select + disabilities.k_student_iep, + disabilities.tenant_code, + disabilities.school_year, + disabilities.ed_org_id, + disabilities.disability_descriptor, + disabilities.disability_determination_source_type_descriptor, + disabilities.disability_diagnosis, + disabilities.order_of_disability + {{ edu_edfi_source.extract_extension(model_name='stg_sedm__student_iep_disability_collections', flatten=False) }} + from disabilities +) + +select * from formatted diff --git a/models/sedm_warehouse/fct_student_iep_disability.yml b/models/sedm_warehouse/fct_student_iep_disability.yml new file mode 100644 index 00000000..576787eb --- /dev/null +++ b/models/sedm_warehouse/fct_student_iep_disability.yml @@ -0,0 +1,40 @@ +version: 2 + +models: + - name: fct_student_iep_disability + description: > + ##### Overview: + This fact table lists disabilities associated with each student IEP, as recorded + in the source disability collection. + + ##### Grain: + One row per IEP disability entry, typically unique by `k_student_iep` and + `order_of_disability`. + + config: + tags: ['sedm'] + enabled: "{{ var('edu:sedm:enabled', False) }}" + + constraints: + - type: foreign_key + name: fk__fct_student_iep_disability__k_student_iep + columns: [k_student_iep] + to: ref('fct_student_iep') + to_columns: [k_student_iep] + + tests: + - dbt_utils.unique_combination_of_columns: + arguments: + combination_of_columns: + - k_student_iep + - order_of_disability + + columns: + - name: k_student_iep + - name: tenant_code + - name: school_year + - name: ed_org_id + - name: disability_descriptor + - name: disability_determination_source_type_descriptor + - name: disability_diagnosis + - name: order_of_disability