pulse-code 1.0.1__tar.gz → 1.0.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (108) hide show
  1. pulse_code-1.0.2/PKG-INFO +349 -0
  2. pulse_code-1.0.2/README.md +331 -0
  3. {pulse_code-1.0.1 → pulse_code-1.0.2}/pyproject.toml +6 -5
  4. pulse_code-1.0.2/src/pulse/cdc_open_catalog.py +74 -0
  5. pulse_code-1.0.2/src/pulse/cli.py +2061 -0
  6. pulse_code-1.0.2/src/pulse/data/cdc_open_catalog.json +1089 -0
  7. pulse_code-1.0.2/src/pulse/data/seer_var_formats.json +631 -0
  8. pulse_code-1.0.2/src/pulse/grasp_catalog.py +145 -0
  9. pulse_code-1.0.2/src/pulse/grasp_client.py +124 -0
  10. pulse_code-1.0.2/src/pulse/grasp_sdk.py +334 -0
  11. pulse_code-1.0.2/src/pulse/nis_catalog.py +195 -0
  12. pulse_code-1.0.2/src/pulse/nis_parser.py +106 -0
  13. pulse_code-1.0.2/src/pulse/nis_sdk.py +271 -0
  14. pulse_code-1.0.2/src/pulse/nssp_client.py +103 -0
  15. pulse_code-1.0.2/src/pulse/nssp_sdk.py +130 -0
  16. pulse_code-1.0.2/src/pulse/seer_catalog.py +107 -0
  17. pulse_code-1.0.2/src/pulse/seer_client.py +77 -0
  18. pulse_code-1.0.2/src/pulse/seer_sdk.py +250 -0
  19. pulse_code-1.0.2/src/pulse/soda_client.py +84 -0
  20. pulse_code-1.0.2/src/pulse/wisqars_catalog.py +150 -0
  21. pulse_code-1.0.2/src/pulse/wisqars_sdk.py +221 -0
  22. pulse_code-1.0.2/src/pulse_code.egg-info/PKG-INFO +349 -0
  23. {pulse_code-1.0.1 → pulse_code-1.0.2}/src/pulse_code.egg-info/SOURCES.txt +17 -0
  24. {pulse_code-1.0.1 → pulse_code-1.0.2}/src/pulse_code.egg-info/requires.txt +3 -3
  25. pulse_code-1.0.1/PKG-INFO +0 -249
  26. pulse_code-1.0.1/README.md +0 -232
  27. pulse_code-1.0.1/src/pulse/cli.py +0 -984
  28. pulse_code-1.0.1/src/pulse_code.egg-info/PKG-INFO +0 -249
  29. {pulse_code-1.0.1 → pulse_code-1.0.2}/LICENSE +0 -0
  30. {pulse_code-1.0.1 → pulse_code-1.0.2}/setup.cfg +0 -0
  31. {pulse_code-1.0.1 → pulse_code-1.0.2}/src/pulse/__init__.py +0 -0
  32. {pulse_code-1.0.1 → pulse_code-1.0.2}/src/pulse/__main__.py +0 -0
  33. {pulse_code-1.0.1 → pulse_code-1.0.2}/src/pulse/catalog.py +0 -0
  34. {pulse_code-1.0.1 → pulse_code-1.0.2}/src/pulse/data/catalog.json +0 -0
  35. {pulse_code-1.0.1 → pulse_code-1.0.2}/src/pulse/data/queries_index.json +0 -0
  36. {pulse_code-1.0.1 → pulse_code-1.0.2}/src/pulse/data/variable_labels.json +0 -0
  37. {pulse_code-1.0.1 → pulse_code-1.0.2}/src/pulse/llm_builder.py +0 -0
  38. {pulse_code-1.0.1 → pulse_code-1.0.2}/src/pulse/matcher.py +0 -0
  39. {pulse_code-1.0.1 → pulse_code-1.0.2}/src/pulse/queries/aids-cases-by-year-1981-1999-req.xml +0 -0
  40. {pulse_code-1.0.1 → pulse_code-1.0.2}/src/pulse/queries/births-by-year-1995-2002-req.xml +0 -0
  41. {pulse_code-1.0.1 → pulse_code-1.0.2}/src/pulse/queries/births-by-year-2003-2006-req.xml +0 -0
  42. {pulse_code-1.0.1 → pulse_code-1.0.2}/src/pulse/queries/births-by-year-2007-2024-req.xml +0 -0
  43. {pulse_code-1.0.1 → pulse_code-1.0.2}/src/pulse/queries/cancer-incidence-by-site-by-year-1999-2022-req.xml +0 -0
  44. {pulse_code-1.0.1 → pulse_code-1.0.2}/src/pulse/queries/cancer-mortality-by-site-by-year-2018-2023-req.xml +0 -0
  45. {pulse_code-1.0.1 → pulse_code-1.0.2}/src/pulse/queries/covid-deaths-by-race-2020-2023-req.xml +0 -0
  46. {pulse_code-1.0.1 → pulse_code-1.0.2}/src/pulse/queries/drug-deaths-by-month-1999-2020-req.xml +0 -0
  47. {pulse_code-1.0.1 → pulse_code-1.0.2}/src/pulse/queries/drug-deaths-by-month-2018-2024-req.xml +0 -0
  48. {pulse_code-1.0.1 → pulse_code-1.0.2}/src/pulse/queries/drug-deaths-by-year-1999-2020-req.xml +0 -0
  49. {pulse_code-1.0.1 → pulse_code-1.0.2}/src/pulse/queries/drug-deaths-by-year-2018-2024-req.xml +0 -0
  50. {pulse_code-1.0.1 → pulse_code-1.0.2}/src/pulse/queries/fentanyl-deaths-by-month-1999-2020-req.xml +0 -0
  51. {pulse_code-1.0.1 → pulse_code-1.0.2}/src/pulse/queries/fentanyl-deaths-by-month-2018-2024-req.xml +0 -0
  52. {pulse_code-1.0.1 → pulse_code-1.0.2}/src/pulse/queries/fetal-deaths-by-cause-by-year-2014-2024-req.xml +0 -0
  53. {pulse_code-1.0.1 → pulse_code-1.0.2}/src/pulse/queries/fetal-deaths-by-year-2005-2024-req.xml +0 -0
  54. {pulse_code-1.0.1 → pulse_code-1.0.2}/src/pulse/queries/heart-vs-cancer-by-sex-2018-2023-req.xml +0 -0
  55. {pulse_code-1.0.1 → pulse_code-1.0.2}/src/pulse/queries/heat-wave-days-by-county-req.xml +0 -0
  56. {pulse_code-1.0.1 → pulse_code-1.0.2}/src/pulse/queries/infant-mortality-2018-2023-req.xml +0 -0
  57. {pulse_code-1.0.1 → pulse_code-1.0.2}/src/pulse/queries/infant-mortality-by-cause-by-year-2007-2023-req.xml +0 -0
  58. {pulse_code-1.0.1 → pulse_code-1.0.2}/src/pulse/queries/maternal-mortality-by-year-1999-2020-req.xml +0 -0
  59. {pulse_code-1.0.1 → pulse_code-1.0.2}/src/pulse/queries/maternal-mortality-by-year-2018-2024-req.xml +0 -0
  60. {pulse_code-1.0.1 → pulse_code-1.0.2}/src/pulse/queries/mortality-by-race-sex-2018-2023-req.xml +0 -0
  61. {pulse_code-1.0.1 → pulse_code-1.0.2}/src/pulse/queries/mortality-by-year-cause-1979-1998-req.xml +0 -0
  62. {pulse_code-1.0.1 → pulse_code-1.0.2}/src/pulse/queries/mortality-by-year-cause-1999-2020-req.xml +0 -0
  63. {pulse_code-1.0.1 → pulse_code-1.0.2}/src/pulse/queries/mortality-by-year-cause-2021-2024-req.xml +0 -0
  64. {pulse_code-1.0.1 → pulse_code-1.0.2}/src/pulse/queries/opioid-overdose-deaths-2018-2024-req.xml +0 -0
  65. {pulse_code-1.0.1 → pulse_code-1.0.2}/src/pulse/queries/pm25-by-year-2003-2011-req.xml +0 -0
  66. {pulse_code-1.0.1 → pulse_code-1.0.2}/src/pulse/queries/provisional-births-by-month-2023-req.xml +0 -0
  67. {pulse_code-1.0.1 → pulse_code-1.0.2}/src/pulse/queries/racial-mortality-gap-2018-2023-req.xml +0 -0
  68. {pulse_code-1.0.1 → pulse_code-1.0.2}/src/pulse/queries/std-cases-by-disease-by-year-1984-2014-req.xml +0 -0
  69. {pulse_code-1.0.1 → pulse_code-1.0.2}/src/pulse/queries/suicide-by-sex-1999-2020-req.xml +0 -0
  70. {pulse_code-1.0.1 → pulse_code-1.0.2}/src/pulse/queries/suicide-by-sex-2021-2024-req.xml +0 -0
  71. {pulse_code-1.0.1 → pulse_code-1.0.2}/src/pulse/queries/tb-cases-by-year-1993-2023-req.xml +0 -0
  72. {pulse_code-1.0.1 → pulse_code-1.0.2}/src/pulse/queries/tick-borne-diseases-by-year-2016-2023-req.xml +0 -0
  73. {pulse_code-1.0.1 → pulse_code-1.0.2}/src/pulse/queries/underlying-cause-mortality-by-year-1999-2020-req.xml +0 -0
  74. {pulse_code-1.0.1 → pulse_code-1.0.2}/src/pulse/queries/unintentional-injuries-by-age-2018-2023-req.xml +0 -0
  75. {pulse_code-1.0.1 → pulse_code-1.0.2}/src/pulse/templates/D10-base.xml +0 -0
  76. {pulse_code-1.0.1 → pulse_code-1.0.2}/src/pulse/templates/D104-base.xml +0 -0
  77. {pulse_code-1.0.1 → pulse_code-1.0.2}/src/pulse/templates/D117-base.xml +0 -0
  78. {pulse_code-1.0.1 → pulse_code-1.0.2}/src/pulse/templates/D128-base.xml +0 -0
  79. {pulse_code-1.0.1 → pulse_code-1.0.2}/src/pulse/templates/D140-base.xml +0 -0
  80. {pulse_code-1.0.1 → pulse_code-1.0.2}/src/pulse/templates/D141-base.xml +0 -0
  81. {pulse_code-1.0.1 → pulse_code-1.0.2}/src/pulse/templates/D149-base.xml +0 -0
  82. {pulse_code-1.0.1 → pulse_code-1.0.2}/src/pulse/templates/D157-base.xml +0 -0
  83. {pulse_code-1.0.1 → pulse_code-1.0.2}/src/pulse/templates/D158-base.xml +0 -0
  84. {pulse_code-1.0.1 → pulse_code-1.0.2}/src/pulse/templates/D159-base.xml +0 -0
  85. {pulse_code-1.0.1 → pulse_code-1.0.2}/src/pulse/templates/D16-base.xml +0 -0
  86. {pulse_code-1.0.1 → pulse_code-1.0.2}/src/pulse/templates/D176-base.xml +0 -0
  87. {pulse_code-1.0.1 → pulse_code-1.0.2}/src/pulse/templates/D178-base.xml +0 -0
  88. {pulse_code-1.0.1 → pulse_code-1.0.2}/src/pulse/templates/D18-base.xml +0 -0
  89. {pulse_code-1.0.1 → pulse_code-1.0.2}/src/pulse/templates/D192-base.xml +0 -0
  90. {pulse_code-1.0.1 → pulse_code-1.0.2}/src/pulse/templates/D204-base.xml +0 -0
  91. {pulse_code-1.0.1 → pulse_code-1.0.2}/src/pulse/templates/D23-base.xml +0 -0
  92. {pulse_code-1.0.1 → pulse_code-1.0.2}/src/pulse/templates/D27-base.xml +0 -0
  93. {pulse_code-1.0.1 → pulse_code-1.0.2}/src/pulse/templates/D31-base.xml +0 -0
  94. {pulse_code-1.0.1 → pulse_code-1.0.2}/src/pulse/templates/D60-base.xml +0 -0
  95. {pulse_code-1.0.1 → pulse_code-1.0.2}/src/pulse/templates/D61-base.xml +0 -0
  96. {pulse_code-1.0.1 → pulse_code-1.0.2}/src/pulse/templates/D66-base.xml +0 -0
  97. {pulse_code-1.0.1 → pulse_code-1.0.2}/src/pulse/templates/D69-base.xml +0 -0
  98. {pulse_code-1.0.1 → pulse_code-1.0.2}/src/pulse/templates/D73-base.xml +0 -0
  99. {pulse_code-1.0.1 → pulse_code-1.0.2}/src/pulse/templates/D74-base.xml +0 -0
  100. {pulse_code-1.0.1 → pulse_code-1.0.2}/src/pulse/templates/D76-base.xml +0 -0
  101. {pulse_code-1.0.1 → pulse_code-1.0.2}/src/pulse/templates/D77-base.xml +0 -0
  102. {pulse_code-1.0.1 → pulse_code-1.0.2}/src/pulse/templates/D8-base.xml +0 -0
  103. {pulse_code-1.0.1 → pulse_code-1.0.2}/src/pulse/templates/D80-base.xml +0 -0
  104. {pulse_code-1.0.1 → pulse_code-1.0.2}/src/pulse/templates/D81-base.xml +0 -0
  105. {pulse_code-1.0.1 → pulse_code-1.0.2}/src/pulse/wonder_client.py +0 -0
  106. {pulse_code-1.0.1 → pulse_code-1.0.2}/src/pulse_code.egg-info/dependency_links.txt +0 -0
  107. {pulse_code-1.0.1 → pulse_code-1.0.2}/src/pulse_code.egg-info/entry_points.txt +0 -0
  108. {pulse_code-1.0.1 → pulse_code-1.0.2}/src/pulse_code.egg-info/top_level.txt +0 -0
@@ -0,0 +1,349 @@
1
+ Metadata-Version: 2.4
2
+ Name: pulse-code
3
+ Version: 1.0.2
4
+ Summary: CDC WONDER query CLI — explore, build, and refine public health data queries
5
+ License-Expression: CC0-1.0
6
+ Requires-Python: >=3.14
7
+ Description-Content-Type: text/markdown
8
+ License-File: LICENSE
9
+ Requires-Dist: anthropic==0.120.2
10
+ Requires-Dist: openai==2.50.0
11
+ Requires-Dist: pydantic==2.13.4
12
+ Requires-Dist: python-dotenv==1.2.2
13
+ Requires-Dist: requests==2.34.2
14
+ Requires-Dist: rich==15.0.0
15
+ Requires-Dist: socksio==1.0.0
16
+ Requires-Dist: typer==0.27.0
17
+ Dynamic: license-file
18
+
19
+ # Pulse
20
+
21
+ [![PyPI](https://img.shields.io/pypi/v/pulse-code?style=for-the-badge)](https://pypi.org/project/pulse-code/)
22
+ [![Python versions](https://img.shields.io/badge/python-3.14%2B-blue?style=for-the-badge)](https://pypi.org/project/pulse-code/)
23
+ [![Publish](https://img.shields.io/github/actions/workflow/status/fartbagxp/pulse-code/publish.yml?style=for-the-badge&label=publish)](https://github.com/fartbagxp/pulse-code/actions/workflows/publish.yml)
24
+ [![Pages](https://img.shields.io/github/actions/workflow/status/fartbagxp/pulse-code/pages.yml?style=for-the-badge&label=pages)](https://fartbagxp.github.io/pulse-code/)
25
+ [![License](https://img.shields.io/badge/license-CC0--1.0-blue?style=for-the-badge)](LICENSE)
26
+
27
+ CDC public health data query CLI. Explore datasets, run bundled queries, and use Claude to build and refine custom XML queries — across CDC WONDER, NCI SEER cancer statistics, CDC Open Data, WISQARS injury data, ATSDR GRASP disease surveillance, NSSP ED visits, and NIS vaccination surveys.
28
+
29
+ ## What is this?
30
+
31
+ ![pulse-code demo](docs/demo/pulse-demo.gif)
32
+
33
+ [CDC WONDER](https://wonder.cdc.gov/) (Wide-ranging ONline Data for Epidemiologic Research) is the government's primary interface for public health statistics: drug overdose deaths, maternal mortality, birth rates, COVID deaths by race, suicide trends, vaccine adverse events, and much more. Its XML API is powerful but opaque.
34
+
35
+ `pulse` makes it usable:
36
+
37
+ - **Explore** all datasets with clear descriptions of what they cover and when
38
+ - **Search** by topic to find the right dataset or a working example query
39
+ - **Run** bundled, validated XML queries directly against the CDC API
40
+ - **Build** new queries from natural language using Claude
41
+ - **Refine** existing queries with conversational feedback
42
+
43
+ Beyond WONDER, `pulse` gives direct access to six more live CDC/NCI/ATSDR sources — no LLM required for those, just a dataset lookup and a query: `seer`, `cdc-open`, `wisqars`, `grasp`, `nssp`, and `nis`.
44
+
45
+ ## Setup
46
+
47
+ ```bash
48
+ # From PyPI (requires Python 3.14+)
49
+ pip install pulse-code
50
+
51
+ # Or from source
52
+ uv sync
53
+
54
+ # For build/query/refine/compare/chat commands, set your Anthropic API key:
55
+ export ANTHROPIC_API_KEY=sk-ant-...
56
+ # or put it in a .env file:
57
+ echo "ANTHROPIC_API_KEY=sk-ant-..." > .env
58
+ ```
59
+
60
+ ### LLM provider
61
+
62
+ `pulse` defaults to Anthropic Claude but can also run against an Azure
63
+ OpenAI Foundry deployment (e.g. GPT-5.4). Select the provider with
64
+ `LLM_PROVIDER` (defaults to `anthropic`):
65
+
66
+ ```bash
67
+ # Anthropic (default), needs ANTHROPIC_API_KEY as above
68
+
69
+ # Azure OpenAI Foundry
70
+ export LLM_PROVIDER=azure_openai
71
+ export AZURE_OPENAI_API_KEY=...
72
+ export AZURE_OPENAI_ENDPOINT=https://<your-resource>.openai.azure.com
73
+ export AZURE_OPENAI_DEPLOYMENT=<your-gpt-5.4-deployment-name>
74
+ export AZURE_OPENAI_API_VERSION=<api-version-your-resource-supports>
75
+ ```
76
+
77
+ All four `AZURE_OPENAI_*` variables are required when `LLM_PROVIDER=azure_openai`;
78
+ `pulse` will tell you which ones are missing. These can also go in a `.env`
79
+ file alongside `ANTHROPIC_API_KEY`.
80
+
81
+ If the LLM endpoint isn't directly reachable (e.g. an Azure OpenAI resource
82
+ with public network access disabled, requiring a private endpoint), bridge
83
+ the connection through a proxy with `LLM_HTTP_PROXY`. Applies to both
84
+ providers, and supports `http://`, `https://`, `socks5://`, and `socks5h://`
85
+ (DNS resolved through the proxy):
86
+
87
+ ```bash
88
+ export LLM_HTTP_PROXY=socks5h://user:pass@host:port
89
+ ```
90
+
91
+ ## Commands
92
+
93
+ ### `pulse datasets` — what's available
94
+
95
+ ```bash
96
+ pulse datasets # all datasets
97
+ pulse datasets --topic Mortality # filter by topic
98
+ pulse datasets --json # JSON output
99
+ ```
100
+
101
+ Shows all 26+ CDC WONDER datasets with: topic, year range, what the data covers, number of bundled example queries, and whether age-adjusted rates are available.
102
+
103
+ **Topics:** Mortality · Infant Mortality · Natality · Environment · Vaccine Safety · Infectious Disease
104
+
105
+ ### `pulse info <ID>` — deep dive on a dataset
106
+
107
+ ```bash
108
+ pulse info D176 # Provisional Mortality (2018–present)
109
+ pulse info D66 # Natality / birth data
110
+ pulse info D8 # VAERS vaccine adverse events
111
+ ```
112
+
113
+ Shows: subject description, available measures, key grouping dimensions, and all bundled example queries for that dataset.
114
+
115
+ ### `pulse search "<topic>"` — find what you need
116
+
117
+ ```bash
118
+ pulse search "opioid overdose deaths by state"
119
+ pulse search "maternal mortality by race"
120
+ pulse search "birth rates 2010 to 2020"
121
+ pulse search "tick-borne disease cases" --queries # queries only
122
+ pulse search "recent COVID deaths" --datasets # datasets only
123
+ ```
124
+
125
+ ### `pulse list-queries` — all bundled example queries
126
+
127
+ ```bash
128
+ pulse list-queries
129
+ pulse list-queries --dataset D176 # filter by dataset
130
+ ```
131
+
132
+ 23 working XML queries covering: drug/opioid/fentanyl deaths, maternal mortality, births, COVID deaths by race, suicide, tick-borne diseases, racial mortality gap, infant mortality, heart disease vs. cancer, and more.
133
+
134
+ ### `pulse seer` — NCI SEER cancer statistics
135
+
136
+ ```bash
137
+ pulse seer sites --search breast # look up a cancer site code
138
+ pulse seer mortality --site 55 --sex female -f csv
139
+ pulse seer mortality --site 47 --compare-by race -f csv
140
+ pulse seer incidence --site 55 --stage 104 -f csv
141
+ pulse seer by-age --site 1 -f csv
142
+ pulse seer compare-sites 55 47 66 -f csv # breast vs. lung vs. melanoma
143
+ ```
144
+
145
+ Cancer incidence and U.S. mortality rates/counts by site, sex, race, and age group, back to 1975 — calls the same unauthenticated JSON endpoints [SEER*Explorer](https://seer.cancer.gov/statistics-network/explorer/) itself uses. No API key needed.
146
+
147
+ ### `pulse cdc-open` — CDC Open Data (data.cdc.gov)
148
+
149
+ ```bash
150
+ pulse cdc-open list # 60+ datasets: mortality, vaccination, wastewater, NNDSS, HAI, and more
151
+ pulse cdc-open list --search wastewater
152
+ pulse cdc-open query leading_death --where "year='2015'" -f csv
153
+ pulse cdc-open query bi63-dtpu --where "state='California'" --limit 500 -f json
154
+ ```
155
+
156
+ Raw [SODA](https://dev.socrata.com/) queries (`--where`, `--select`, `--group`, `--order`) against any of the registered Socrata datasets, by registry key or by Socrata ID directly. No API key needed (set `CDC_DATA_APP_TOKEN` for a higher rate limit).
157
+
158
+ ### `pulse wisqars` — WISQARS injury & violence data
159
+
160
+ ```bash
161
+ pulse wisqars list
162
+ pulse wisqars mortality --intent Suicide --mechanism Firearm -f csv # 1999-2016
163
+ pulse wisqars national --intent FA_Deaths --type year -f csv # 2019-present
164
+ pulse wisqars state --intent Drug_OD --year 2023 -f table
165
+ pulse wisqars county --state Texas --intent FA_Deaths --year 2023
166
+ pulse wisqars tract --state Texas --intent All_Homicide --year 2022 # census-tract granularity
167
+ pulse wisqars query t6u2-f84c --where "intent='Drug_OD' AND type='year'"
168
+ ```
169
+
170
+ Fatal firearm/suicide/homicide/drug-overdose data from [WISQARS](https://wisqars.cdc.gov/) at national, state, county, and census-tract granularity, backed by data.cdc.gov Socrata datasets (same client as `cdc-open`). No API key needed.
171
+
172
+ ### `pulse grasp` — ATSDR GRASP disease surveillance
173
+
174
+ ```bash
175
+ pulse grasp list
176
+ pulse grasp hantavirus cases --outcome Dead -f table # pre-1993-present
177
+ pulse grasp hantavirus by-year -f table
178
+ pulse grasp hantavirus by-state -f table
179
+ pulse grasp fluview ili-data --region nat --region ca --region tx --epiweeks 202001-202026
180
+ pulse grasp fluview ili-by-region --epiweeks 201940-202020 -f table
181
+ pulse grasp fluview clinical-data --region nat --epiweeks 202001-202026
182
+ pulse grasp flusurv data --location CA --location OH --epiweeks 202001-202020 -f csv
183
+ pulse grasp flusurv by-season --location CA -f table
184
+ pulse grasp flusurv by-location --season 2019-20 -f table
185
+ ```
186
+
187
+ Hantavirus case data, FluView ILINet influenza-like-illness activity, WHO/NREVSS clinical lab flu positivity, and FluSurv-NET hospitalization rates — sourced from [gis.cdc.gov/grasp](https://gis.cdc.gov/grasp/) and the CMU Delphi Epidata API. No API key needed. Note: repeatable options like `--region`/`--location` take one value per flag (`--region nat --region ca`), unlike `health`'s argparse CLI which accepts space-separated lists after a single flag.
188
+
189
+ ### `pulse nssp` — emergency department visit surveillance
190
+
191
+ ```bash
192
+ pulse nssp query covid --geo-type state --geo-value ca -f csv
193
+ pulse nssp query influenza --geo-type nation --geo-value us
194
+ pulse nssp national --start 202401 -f csv # all 4 pathogens, national
195
+ pulse nssp hhs rsv --region 4 -f table
196
+ ```
197
+
198
+ Weekly % of ED visits attributed to COVID/flu/RSV from the [National Syndromic Surveillance Program](https://www.cdc.gov/nssp/), via the CMU Delphi Epidata API. Time values use epiweek format (`YYYYWW`, e.g. `202518` = week 18 of 2025). No API key needed.
199
+
200
+ ### `pulse nis` — National Immunization Survey (vaccination coverage)
201
+
202
+ ```bash
203
+ pulse nis list child # available years, 2011-2022
204
+ pulse nis stream child 2022 --limit 10 -f json # raw respondent microdata
205
+ pulse nis rates child 2022 -f table # state-level UTD rates
206
+ pulse nis rates teen 2022 --vaccines P_UTDHPV13 -f csv
207
+ pulse nis national child 2022 # national UTD summary
208
+ ```
209
+
210
+ Childhood (19–35mo) and teen (13–17yr) vaccination coverage from CDC's annual random-digit-dial survey. Files are large fixed-width `.dat` files (50–200MB) streamed directly — nothing is written to disk. **Known issue:** CDC has restructured its NIS file hosting since this registry's URLs were last verified (some years now live under `www.cdc.gov/nis/media/files/...` or `ftp.cdc.gov/pub/Vaccines_NIS/` instead of the legacy `ftp.cdc.gov/.../nis/NISPUF{YY}-formats.sas` path baked into `nis_catalog.py`), so live `stream`/`rates`/`national` calls currently 404 for at least the 2015+ years — the same pre-existing gap affects `health`'s own `nis` module. The CLI plumbing and DAT-streaming parser are unit-tested and correct; only the hardcoded per-year URLs need refreshing against CDC's current hosting.
211
+
212
+ ### `pulse run <query>` — execute a query
213
+
214
+ ```bash
215
+ # Run a bundled query by filename (no path needed)
216
+ pulse run drug-deaths-by-year-2018-2024-req.xml
217
+
218
+ # Output formats
219
+ pulse run opioid-overdose-deaths-2018-2024-req.xml -f csv
220
+ pulse run mortality-by-year-cause-2021-2024-req.xml -f json
221
+ pulse run births-by-year-2007-2024-req.xml -f table -o births.csv
222
+
223
+ # Run your own query file
224
+ pulse run /path/to/my-query.xml
225
+ ```
226
+
227
+ Hits the live CDC WONDER API. No login required; CDC requires a ~2-minute cooldown between queries.
228
+
229
+ ### `pulse build "<description>"` — build a query with Claude
230
+
231
+ ```bash
232
+ # Requires ANTHROPIC_API_KEY
233
+ pulse build "drug overdose deaths by state and year 2018-2023"
234
+ pulse build "maternal mortality by race, 2018-2023" -o maternal-race.xml
235
+ pulse build "birth rates by age of mother 2010 to 2024" --no-suggest
236
+ ```
237
+
238
+ Suggests closest existing queries first, then calls Claude to build a new XML query. The LLM selects the right dataset and generates overrides merged onto a validated base template.
239
+
240
+ ### `pulse query "<description>"` — build and run in one step
241
+
242
+ ```bash
243
+ pulse query "fentanyl deaths by state 2020-2024" -f csv
244
+ pulse query "infant mortality by race 2018-2023" --save-xml infant-race.xml
245
+ ```
246
+
247
+ ### `pulse refine <file> "<feedback>"` — iterate on a query
248
+
249
+ ```bash
250
+ pulse refine opioid-overdose-deaths-2018-2024-req.xml "break it down by state"
251
+ pulse refine drug-deaths-by-year-2018-2024-req.xml "add sex breakdown" -o drug-sex.xml
252
+ pulse refine drug-deaths-by-year-2018-2024-req.xml "show monthly not yearly" --run -f csv
253
+ ```
254
+
255
+ ## Testing
256
+
257
+ ```bash
258
+ uv run pytest # unit tests only, fast, no network (default)
259
+ uv run pytest -m integration # + integration tests (see below)
260
+ ```
261
+
262
+ Unit tests cover catalog/matcher lookups, XML template merging (including
263
+ the CDC WONDER radio-button-trap regression), AAR constraints, provider
264
+ selection, and the offline-network-free CLI commands.
265
+
266
+ Integration tests (`tests/integration/`) are excluded by default and split
267
+ into two kinds:
268
+
269
+ - **`test_socks_proxy_integration.py`**: always runs. Spins up a local
270
+ SOCKS5 relay and a local mock LLM HTTP server, so it actually exercises
271
+ `LLM_HTTP_PROXY` end-to-end (real SOCKS handshake, real HTTP
272
+ request/response) without needing real Azure/Anthropic credentials.
273
+ - **`test_llm_provider_live.py`**: hits whatever `ANTHROPIC_API_KEY` /
274
+ `LLM_PROVIDER=azure_openai` + `AZURE_OPENAI_*` / `LLM_HTTP_PROXY` you
275
+ actually have configured. Skips if credentials aren't set; also skips
276
+ (rather than fails) if the provider is reachable but blocked at the
277
+ network layer (e.g. an Azure OpenAI resource with public access disabled
278
+ and no working proxy). That's an environment gap, not a code defect.
279
+
280
+ ## Bundled Datasets (with base templates)
281
+
282
+ | ID | Subject | Years |
283
+ | ----------- | ------------------------------------------------------------- | ------------ |
284
+ | D176 | Provisional mortality: opioids, COVID, suicide, heart disease | 2018–present |
285
+ | D157 | Final mortality, single race (MCD+UCD) | 2018–2023 |
286
+ | D158 | Underlying cause of death, single race: maternal mortality | 2018–2023 |
287
+ | D77 | Multiple cause of death: drug deaths (historical) | 1999–2020 |
288
+ | D76 | Underlying cause of death: suicide, cancer (historical) | 1999–2020 |
289
+ | D141 | MCD with US-Mexico border regions | 1999–2020 |
290
+ | D140 | Compressed mortality ICD-10 | 1999–2016 |
291
+ | D16 | Compressed mortality ICD-9 | 1979–1998 |
292
+ | D74 | Compressed mortality ICD-8 | 1968–1978 |
293
+ | D69 | Linked birth/infant death records | 2007–2023 |
294
+ | D159 | Linked birth/infant death, expanded race | 2017–2023 |
295
+ | D31/D18/D23 | Linked birth/infant death (historical) | 1995–2006 |
296
+ | D66 | Natality: birth rates, birth outcomes | 2007–2024 |
297
+ | D149 | Natality, expanded race detail | 2016–2024 |
298
+ | D192 | Provisional natality (monthly) | 2023–present |
299
+ | D27/D10 | Natality (historical) | 1995–2006 |
300
+ | D8 | VAERS vaccine adverse events | 1990–present |
301
+ | D104 | Heat wave days by county | 1981–2010 |
302
+ | D60/D80/D81 | NLDAS temperature, sunlight, precipitation | 1979–2011 |
303
+ | D73 | PM2.5 fine particulate matter | 2003–2011 |
304
+ | D61 | MODIS land surface temperature | 2003–2008 |
305
+
306
+ ## Public Health Questions You Can Answer
307
+
308
+ - How did opioid overdose deaths trend from 1999 to today, broken down by drug type?
309
+ - What is the racial gap in COVID-19 mortality?
310
+ - How does maternal mortality differ by race and state?
311
+ - Which states have the highest suicide rates by sex?
312
+ - How have birth rates changed by age of mother since 1995?
313
+ - Are tick-borne disease cases increasing?
314
+ - How do PM2.5 air quality levels correlate with where people live?
315
+ - What are the most common adverse events reported after COVID vaccines?
316
+
317
+ ## Releasing
318
+
319
+ Releases are cut by pushing a tag. `publish.yml` (single workflow, one run
320
+ per tag) handles the rest as three sequential jobs:
321
+
322
+ 1. Bump `version` in `pyproject.toml`, commit it.
323
+ 2. `git tag vX.Y.Z && git push origin vX.Y.Z`
324
+ 3. **`build`** builds the sdist/wheel, failing fast if the tag doesn't match
325
+ `pyproject.toml`'s version.
326
+ 4. **`release`** (needs `build`) creates the GitHub Release with the built
327
+ artifacts attached, the source of truth for what shipped.
328
+ 5. **`publish`** (needs `release`) publishes those same artifacts to PyPI
329
+ (`pulse-code`) via trusted publishing (OIDC) against the `prod`
330
+ environment, with no API tokens stored in the repo.
331
+
332
+ The `needs:` chain means a failure at any step blocks everything after it.
333
+ For example, a PyPI hiccup can't leave a GitHub Release around for a package that
334
+ isn't actually installable. If the `publish` job fails after `release`
335
+ succeeds, use "Re-run failed jobs" on that workflow run rather than
336
+ re-tagging. PyPI publishing is immutable: once a version is published it
337
+ can't be re-uploaded, so a bad release means bumping to a new version.
338
+
339
+ ## Related projects
340
+
341
+ `pulse` is the exploration layer of a three-repo pipeline:
342
+
343
+ ```bash
344
+ pulse-code → health → health-charts
345
+ (explore) (archive) (visualize)
346
+ ```
347
+
348
+ - **[fartbagxp/health](https://github.com/fartbagxp/health)**, a collection of CDC data pipelines (WONDER, data.cdc.gov, NCHS, SEER, WISQARS, GRASP, NSSP, NIS, and more) and the CDC WONDER XML API client and LLM query builder this tool builds on. `pulse`'s SEER, CDC Open Data, WISQARS, GRASP, NSSP, and NIS clients are lightweight, standalone reimplementations of `health`'s equivalent modules — kept dependency-free (just `requests`) rather than depending on `health` directly, which also pulls in `pandas`/`playwright`/`lxml` for its archival pipelines. `pulse` now covers every source `health` does. Where `pulse` is for one-off, ad hoc exploration, `health` is where a query graduates once someone wants it archived on a recurring schedule: 23 of the 36 saved WONDER queries in `src/pulse/queries/` are also saved in `health`'s `src/wonder/queries/`, each wrapped there in a small `fetch_*.py` script that runs on a schedule and commits the result as a CSV under `data/raw/wonder/`. The other 13 (cancer incidence/mortality by site, fetal deaths, PM2.5, TB, STI cases, heat-wave days, etc.) are exploration-only for now, candidates for `health` if any of them turn into a recurring need.
349
+ - **[fartbagxp/health-charts](https://github.com/fartbagxp/health-charts)**, the dashboard at the end of the pipeline. It reads the CSVs `health` archives (including the ones seeded by `pulse`'s queries above) directly from GitHub and renders them as an interactive chart site.