1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
/*!
* # NPPES (National Plan and Provider Enumeration System) Data Library
*
* A Rust library for working with NPPES healthcare provider data.
*
* ## Features
*
* - High performance: Efficient parsing of large datasets with progress tracking
* - Builder pattern for loading datasets
* - Querying and statistical analysis
* - Multiple export formats: JSON, CSV, SQL, and more
* - Indexing for provider lookups
* - Modular design: Load only the data required
* - Type-safe data structures with validation
*
* ## Quick Start
*
* ```no_run
* use nppes::prelude::*;
*
* # fn main() -> Result<()> {
* // Load all NPPES data from a directory
* let dataset = NppesDataset::load_standard("./data")?;
*
* // Query providers
* let ca_cardiologists = dataset
* .query()
* .state("CA")
* .specialty("Cardiology")
* .active_only()
* .execute();
*
* println!("Found {} cardiologists in California", ca_cardiologists.len());
*
* // Export results
* dataset.export_subset(
* "ca_cardiologists.json",
* |p| p.mailing_address.state.as_ref().map(|s| s.as_code()) == Some("CA"),
* ExportFormat::Json
* )?;
* # Ok(())
* # }
* ```
*
* ## Loading Data
*
* ### Using the Builder Pattern
*
* ```no_run
* # use nppes::prelude::*;
* # fn main() -> Result<()> {
* let dataset = NppesDatasetBuilder::new()
* .main_data("data/npidata_pfile_20240101-20240107.csv")
* .taxonomy_reference("data/nucc_taxonomy_240.csv")
* .other_names("data/othername_pfile_20240101-20240107.csv")
* .skip_invalid_records(true)
* .build()?;
* # Ok(())
* # }
* ```
*
* ### Memory Estimation
*
* ```no_run
* # use nppes::prelude::*;
* # fn main() -> Result<()> {
* // Estimate memory requirements before loading
* let estimate = NppesReader::estimate_memory_usage("data/npidata_pfile.csv")?;
* println!("Estimated memory usage: {}", estimate.estimated_memory_human);
* # Ok(())
* # }
* ```
*
* ## Querying Data
*
* ### Find Providers by Criteria
*
* ```no_run
* # use nppes::prelude::*;
* # fn main() -> Result<()> {
* # let dataset = NppesDataset::load_standard("./data")?;
* // Find all active primary care physicians in New York
* let ny_pcps = dataset
* .query()
* .state("NY")
* .entity_type(EntityType::Individual)
* .specialty("Primary Care")
* .active_only()
* .execute();
*
* // Get providers by NPI (O(1) lookup if indexed)
* if let Some(provider) = dataset.get_by_npi(&Npi::new("1234567890".to_string())?) {
* println!("Provider: {}", provider.display_name());
* }
* # Ok(())
* # }
* ```
*
* ### Statistical Analysis
*
* ```no_run
* # use nppes::prelude::*;
* # fn main() -> Result<()> {
* # let dataset = NppesDataset::load_standard("./data")?;
* // Get dataset statistics
* let stats = dataset.statistics();
* stats.print_summary();
*
* // Use analytics engine for advanced queries
* let analytics = dataset.analytics();
* let top_states = analytics.top_states_by_provider_count(10);
* # Ok(())
* # }
* ```
*
* ## Exporting Data
*
* ### Export to Different Formats
*
* ```no_run
* # use nppes::prelude::*;
* # use nppes::export::SqlDialect;
* # fn main() -> Result<()> {
* # let dataset = NppesDataset::load_standard("./data")?;
* // Export to JSON
* dataset.export_json("providers.json")?;
*
* // Export to JSON Lines (streaming format)
* dataset.export_json_lines("providers.jsonl")?;
*
* // Export to normalized CSV files
* dataset.export_csv("providers.csv")?;
*
* // Export to SQL
* dataset.export_sql("providers.sql", SqlDialect::PostgreSQL)?;
*
* // Export to Parquet (if enabled)
* #[cfg(feature = "arrow-export")]
* dataset.export_parquet("providers.parquet")?;
*
* // Export filtered subset
* dataset.export_subset(
* "texas_organizations.json",
* |p| p.entity_type == Some(EntityType::Organization) &&
* p.mailing_address.state.as_ref().map(|s| s.as_code()) == Some("TX"),
* ExportFormat::Json
* )?;
* # Ok(())
* # }
* ```
*
* ## Configuration
*
* ### Using Configuration
*
* ```no_run
* # use nppes::prelude::*;
* # use nppes::config::{NppesConfig, ValidationLevel};
* # fn main() -> Result<()> {
* // Use a custom configuration
* let config = NppesConfig::performance();
* nppes::config::set_global_config(config);
*
* // Or build your own
* let config = ConfigBuilder::new()
* .progress_bar(false)
* .validation_level(ValidationLevel::Basic)
* .skip_invalid_records(true)
* .build();
* # Ok(())
* # }
* ```
*
* ## Performance Considerations
*
* 1. Use indexes for fast lookups
* 2. Enable parallel processing with the `parallel` feature
* 3. Skip invalid records for resilient parsing
* 4. Estimate memory requirements before loading large files
* 5. Enable progress bars for long operations
*
* ## NPPES Data Files
*
* The library supports the following NPPES file types:
*
* - Main Data File: `npidata_pfile_YYYYMMDD-YYYYMMDD.csv`
* - Other Names: `othername_pfile_YYYYMMDD-YYYYMMDD.csv`
* - Practice Locations: `pl_pfile_YYYYMMDD-YYYYMMDD.csv`
* - Endpoints: `endpoint_pfile_YYYYMMDD-YYYYMMDD.csv`
* - Taxonomy Reference: `nucc_taxonomy_XXX.csv`
*
* Data files are available at: https://download.cms.gov/nppes/NPI_Files.html
*/
// Re-export error types from root
pub use ;
// Public modules
/// Prelude module for convenient imports
///
/// Import everything you need with:
/// ```
/// use nppes::prelude::*;
/// ```
/// NPPES data constants
/// Common recipes and utility functions