[PULL REQUEST] Updating fertility scripts - #162
Open
KPHSANDAG wants to merge 5 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR migrates fertility (birth) inputs from local data/births files to SQL-backed sources in the socioec_data warehouse (notably [vital_statistics].[cdc_wonder_fertility]), and removes the legacy rates_map configuration/mapping.
Changes:
- Added SQL queries to load/shape CDC WONDER fertility data, compute “Not Stated” inflation factors, and load DOF P3 projected female populations (15–44) for rate denominators.
- Updated
birth_rates.pyto pull fertility inputs from the database and removed therates_mappathway from configuration and parsing. - Removed the legacy
rates_map.ymlartifact and references fromREADME.md,config.yml, and runtime config parsing/utilities.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| sql/fertility/dof_projections_p3.sql | New query to pull DOF P3 female population by race/age for fertility denominators. |
| sql/fertility/cdc_wonder_fertility.sql | New query to shape CDC WONDER fertility data into CCM-compatible race/age outputs. |
| sql/fertility/cdc_wonder_fertility_inflation.sql | New query to compute inflation factors for “Not Stated” records. |
| python/input_modules/birth_rates.py | Switched birth rate computation to SQL inputs and new geo hierarchy logic. |
| python/input_modules/death_rates.py | Added module docstring. |
| python/parsers.py | Removed rates_map parsing/validation and related attribute. |
| python/utils.py | Removed RATES_MAP runtime config wiring. |
| README.md | Removed rates_map configuration documentation. |
| config.yml | Removed rates_map configuration entry. |
| rates_map.yml | Deleted legacy local births mapping file. |
Suppressed comments (3)
python/input_modules/birth_rates.py:59
- Avoid using
print()in library/runtime code; it bypasses the configured logging handlers (console/file) and makes output harder to control. Use the module logger instead.
print("CDC WONDER fertility inflation factors loaded from database:")
python/input_modules/birth_rates.py:86
- Avoid using
print()in library/runtime code; it bypasses the configured logging handlers (console/file) and makes output harder to control. Use the module logger instead.
print("DOF P3 projections loaded from database:")
sql/fertility/cdc_wonder_fertility.sql:75
- The UNION expansion is documented as using the "All Races" + "Not Hispanic or Latino" rows to synthesize missing race categories, but the WHERE clause doesn’t restrict
hispanic_origin. If "All Races" exists for Hispanic rows, this would incorrectly fabricate these categories for Hispanics as well.
,[births]
FROM [data]
WHERE [race] = 'All Races' AND [year] = @year AND [year] <= 2019
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
GregorSchroeder
requested changes
Aug 6, 2026
GregorSchroeder
left a comment
Contributor
There was a problem hiding this comment.
We need to revisit how we load births in for the Vital Statistics repository
- fertility rates are provided down to the county level
- product differentiation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Describe this pull request. What changes are being made?
This pr changes the source of fertility data from the data folders
data/birthsto thesocioec_datawarehouse containing[vital_statistics].[cdc_wonder_fertility]. Existing scripts inbirth_rates.pyhave been modified to account for the source change and new sql files calling the data have been added. All mentions ofrates_maphave been removed.Validation and testing
Successful run can be seen in [CohortComponentModel].[outputs].[rates] or in the streamlit report where
run_id = 62.What issues does this pull request address?
closes #161
Additional context
N/A