Generate Documentation
CIIDCIID-ReportsG3GitHub
  • Introduction to Generate
  • User Guide
    • Getting Started
      • Requesting Generate
      • User Roles and Logging In
      • Navigating Generate
    • Resources
    • Data Population Summary
      • Producing Reports
      • Reports
      • Running Reports
    • Standard Reports
      • EDFacts Reports
        • Creating Submission Files
      • SPP/APR Reports
      • Reports Library
    • Settings
      • Toggle
      • Update
      • Metadata
      • Data Migration
    • Quality Assurance
    • Support
  • Developer Guides
    • Getting Started
    • Installation
      • OAuth Configuration
      • Configuring Metadata Updates
      • Subfolder configuration
      • Optional Installations
      • Azure Installation Guide
      • Upgrade
        • Generate Update
        • Optional Installations
    • Migration
      • Fact Type Table
        • Assessment Fact Type
        • Child Count Fact Type
        • Directory Fact Type
        • Discipline Fact Type
        • Exiting Fact Type
        • Membership
        • Staff
    • Generate Utilities
      • File Comparison
        • Loading Files
        • Run the File Comparison
        • Reviewing Results
        • Researching Mismatches
      • Staging Validation
        • Staging Table Validation Process
      • Rebuild Indexes
      • Cleanup Grades Offered
      • Cleanup Debug Tables
      • Source System Reference Data Mapping Utility
        • Source System Reference Data
      • Staging Table Snapshot
      • Fact Type Table Validation Process
      • Debug Views for Staging and the Fact tables
    • Generate Architecture
    • GitHub Guide
    • Discord Guide
    • Working With Generate Code
      • Migration Stored Procedures
        • Staging.RUN_DMC
        • RDS.Get_MembershipReportData
        • Staging.Staging-to-DimPeople
        • Staging.Staging-To-DimPeople_K12Students
        • Staging.Staging-to-FactK12ProgramParticipations
        • Staging.Staging-To-FactK12SeclusionsOrRestraints
        • Staging.Staging-to-FactK12StudentCounts_ChildCount
        • Staging.Staging-to-FactK12StudentCounts_Chronic
        • Staging.Staging-to-FactK12StudentCounts_Dropout
        • Staging.Staging-to-FactK12StudentCounts_GraduationRate
        • Staging.Staging-to-FactK12StudentCounts_Homeless
        • Staging.Staging-to-FactK12StudentCounts_HSGradPSEnroll
        • Staging.Staging-to-FactK12StudentCounts_Membership
        • Staging.Staging-to-FactK12StudentCounts_MigrantEducationProgram
        • Staging.Staging-to-FactK12StudentCounts_NeglectedOrDelinquent
        • Staging.Staging-to-FactK12StudentCounts_SpecEdExit
        • Staging.Staging-to-FactK12StudentCourseSections
        • Staging.Staging-to-FactK12StudentDisciplines
        • Staging.Staging-to-FactK12StudentEnrollments
        • Staging.Staging-To-FactSpecialEducation
      • Unit Test By File Spec
        • App.DimK12Staff_TestCase
        • App.DimK12Students_TestCase
        • App.FS002_TestCase
        • App.FS005_TestCase
        • App.FS006_TestCase
        • App.FS007_TestCase
        • App.FS009_TestCase
        • App.FS032_TestCase
        • App.FS033_TestCase
        • App.FS040_TestCase
  • Release Notes
    • Introduction
    • Release Notes 12.4
    • Release Notes 12.3
    • Release Notes 12.2
    • Release Notes 12.1
    • Archive
      • Release Notes 12.0
      • Release Notes 11.4
      • Release Notes 11.3
      • Release Notes 11.2
      • Release Notes 11.1
      • Release Notes 11.0
      • Release Notes 5.3
        • Generate 5.3 Office Hour
      • Release Notes 5.2
        • Generate 5.2 Office Hour
      • Release Notes 5.1
        • Generate 5.1 Office Hour
      • Release Notes 5.0
        • Generate 5.0 Office Hour
      • Release Notes 4.1
      • Release Notes 4.0
      • Release Notes 3.8
      • Release Notes 3.7
      • Release Notes 3.6
      • Release Notes 3.5
      • Release Notes 3.4
      • Release Notes 3.3
      • Release Notes 3.2
      • Release Notes 3.1
      • Release Notes 3.0
      • Release Notes 2.4
    • Release Notes 12.3
  • Hot Fixes
    • Hot Fix - 4/13/2023
Powered by GitBook
On this page
  • Overview & Purpose
  • Business Context
  • Parameters
  • Source Tables
  • Temporary Tables
  • Potential Improvements
  • Execution Steps

Was this helpful?

Edit on GitHub
  1. Developer Guides
  2. Working With Generate Code
  3. Unit Test By File Spec

App.FS032_TestCase

Overview & Purpose

This stored procedure is designed to test and validate the accuracy of student count data in the EdFacts reporting system. It creates test cases for various category sets (CSA through CSF, ST1, and TOT) across different reporting levels (SEA, LEA, SCH) and compares expected results with actual results from the reporting system.

Main Functions:

  • Student Count Validation

    To verify that student counts in the EdFacts reporting system match expected counts based on source data

  • Test Case Management

    To create, track, and record test case results for data validation

Key Calculations:

  • Student Count Validation: To count unique students across various demographic and educational categories

    Formula: COUNT(DISTINCT StudentIdentifierState)

    Business Significance: Ensures accurate reporting of student populations for federal/state compliance

    Example: Counting students by grade level, race, and sex for the CSA category set

  • Test Case Management: To determine if expected and actual student counts match

    Formula: CASE WHEN s.StudentCount = ISNULL(Fact.StudentCount, -1) THEN 1 ELSE 0 END

    Business Significance: Provides a pass/fail indicator for each test case

    Example: Comparing expected student counts from staging data with actual counts in the reporting system

Data Transformations:

  • Creating temporary tables for each category set and reporting level combination

  • Aggregating student counts by various demographic and educational attributes

  • Comparing calculated counts with stored counts in the reporting system

  • Recording test results in the App.SqlUnitTestCaseResult table

Expected Output:

The procedure populates the App.SqlUnitTestCaseResult table with test case results, including test case names, details, expected and actual counts, and pass/fail indicators.

Business Context

System: EdFacts Reporting System

Necessity: To ensure accurate reporting of student demographic and educational data to federal and state authorities

Business Rules:

  • Student counts must be calculated based on distinct student identifiers

  • Students must be categorized by various demographic and educational attributes

  • Data must be aggregated at SEA (State), LEA (District), and SCH (School) levels

  • Test cases must validate all required category sets (CSA through CSF, ST1, and TOT)

Result Usage:

Results are used to validate the accuracy of the EdFacts reporting system and identify discrepancies that need correction

Execution Frequency:

Likely executed on an as-needed basis during testing cycles or after data updates

Critical Periods:

  • Before EdFacts submission deadlines

  • After major data updates or system changes

Parameters

Parameter
Data Type
Purpose
Required

@SchoolYear

SMALLINT

Specifies the school year for which to run the test cases

True

Source Tables

debug.vwStudentDetails

Business Purpose: Provides student demographic and educational data for analysis

Columns:

Name
Data Type
Business Purpose

SchoolYear

Unknown

Identifies the academic year

StudentIdentifierState

Unknown

Unique identifier for students within the state

GradeLevelEdFactsCode

Unknown

Standardized code for student grade level

staging.K12Enrollment

Business Purpose: Stores student enrollment data

Columns:

Name
Data Type
Business Purpose

StudentIdentifierState

Unknown

Unique identifier for students within the state

LeaIdentifierSeaAccountability

Unknown

Identifier for the Local Education Agency (district)

RDS.ReportEdFactsK12StudentCounts

Business Purpose: Stores the actual student count data for EdFacts reporting

Columns:

Name
Data Type
Business Purpose

ReportCode

Unknown

Identifies the specific EdFacts report

ReportYear

Unknown

Identifies the reporting year

StudentCount

Unknown

The count of students for a specific category combination

Temporary Tables

#vwStudentDetails

Purpose: Temporary storage of filtered student details from the source view

Columns:

Name
Data Type
Purpose/Calculation

SchoolYear

Unknown

Direct copy from source

StudentIdentifierState

Unknown

Direct copy from source

GradeLevelEdFactsCode

Unknown

Derived from GradeLevelEdFactsCode with transformation for grades below 7

#staging

Purpose: Combines student details with additional attributes needed for testing

Columns:

Name
Data Type
Purpose/Calculation

All columns from #vwStudentDetails

Various

Direct copy from source

EconomicDisadvantageStatusEdFactsCode

Unknown

Derived from staging.PersonStatus.EconomicDisadvantageStatus

MigrantStatusEdFactsCode

Unknown

Derived from staging.PersonStatus.MigrantStatus

HomelessnessStatusEdFactsCode

Unknown

Derived from staging.PersonStatus.HomelessnessStatus

#SEA_CSA, #LEA_CSA, #SCH_CSA (and similar for other category sets)

Purpose: Store aggregated student counts for each category set and reporting level

Columns:

Name
Data Type
Purpose/Calculation

GradeLevelEdFactsCode, RaceEdFactsCode, SexEdFactsCode (varies by category set)

Unknown

Direct copy from #staging

StudentCount

Unknown

COUNT(DISTINCT StudentIdentifierState)

Potential Improvements

Error Handling

Description: Add comprehensive error handling with TRY/CATCH blocks and specific error messages

Benefits: Better troubleshooting and more robust execution

Priority: Medium

Performance

Description: Add appropriate indexes to temporary tables for better join performance

Benefits: Faster execution, especially with large data volumes

Priority: Medium

Code Organization

Description: Refactor repetitive code blocks into dynamic SQL or table-driven approach

Benefits: Reduced code size, easier maintenance

Priority: Low

Documentation

Description: Add more detailed inline documentation about business rules and data transformations

Benefits: Better understanding for future maintainers

Priority: Low

Execution Steps

Step 1: Initialize by dropping any existing temporary tables

Input Data: None

Transformations: None

IF OBJECT_ID('tempdb..#Staging') IS NOT NULL DROP TABLE #Staging

Step 2: Set up unit test metadata

Input Data: Test name, procedure name, scope, and report code

Transformations: None

IF NOT EXISTS (SELECT 1 FROM App.SqlUnitTest WHERE UnitTestName = @UnitTestName) BEGIN INSERT INTO App.SqlUnitTest... END

Step 3: Clear previous test results

Input Data: SqlUnitTestId

Transformations: None

DELETE FROM App.SqlUnitTestCaseResult WHERE SqlUnitTestId = @SqlUnitTestId

Step 4: Create and populate temporary student details table

Input Data: debug.vwStudentDetails

Transformations: Grade level transformation for grades below 7, disability status derivation

select SchoolYear, StudentIdentifierState, ... into #vwStudentDetails from debug.vwStudentDetails vw where SchoolYear = @SchoolYear

Step 5: Create and populate main staging table

Input Data: #vwStudentDetails, staging.K12Enrollment, staging.PersonStatus, RDS dimension tables

Transformations: Derivation of status codes for economic disadvantage, migrant, and homelessness

select vsd.*, case when sps.EconomicDisadvantageStatus = 1 then 'ECODIS' else '' end EconomicDisadvantageStatusEdFactsCode, ... into #staging from #vwStudentDetails vsd inner join staging.K12Enrollment ske ...

Step 6: Process each category set (CSA through TOT) for each reporting level (SEA, LEA, SCH)

Input Data: #staging

Transformations: Aggregation by various dimension combinations

SELECT GradeLevelEdFactsCode, RaceEdFactsCode, SexEdFactsCode, COUNT(DISTINCT StudentIdentifierState) AS StudentCount INTO #SEA_CSA FROM #staging GROUP BY GradeLevelEdFactsCode, RaceEdFactsCode, SexEdFactsCode

Step 7: Compare expected and actual results for each test case

Input Data: Temporary tables with expected counts, RDS.ReportEdFactsK12StudentCounts

Transformations: None

INSERT INTO App.SqlUnitTestCaseResult ... SELECT @SqlUnitTestId, @CategorySet + ' ' + @ReportLevel, 'Grade: ' + s.GradeLevelEdFactsCode + ..., s.StudentCount, Fact.StudentCount, CASE WHEN s.StudentCount = ISNULL(Fact.StudentCount, -1) THEN 1 ELSE 0 END, GETDATE() FROM #SEA_CSA s JOIN RDS.ReportEdFactsK12StudentCounts Fact ...

PreviousApp.FS009_TestCaseNextApp.FS033_TestCase

Was this helpful?