NPPES Data Library
A comprehensive Rust library for working with National Plan and Provider Enumeration System (NPPES) healthcare provider data.
Overview
The NPPES dataset contains information about healthcare providers in the United States, including:
- ~8 million healthcare provider records
- 330+ data columns including NPI numbers, provider information, taxonomy codes
- Entity types: Individual providers (code 1) vs Organizations (code 2)
- Healthcare provider taxonomy codes for specialties
- Geographic information and licensing data
Features
- Type-safe data structures for all NPPES file formats
- CSV parsing and loading with validation and error handling
- Analytics and querying functionality for data analysis
- Schema validation against official NPPES documentation
- Support for all NPPES reference files (Other Names, Practice Locations, Endpoints)
NPPES Data Files Supported
Main Data File
- File:
npidata_pfile_yyyymmdd-yyyymmdd.csv(9.9GB) - Contains: ~8M healthcare provider records with 330+ columns
Reference Files
- Other Name Reference: Additional organization names for Type 2 NPIs
- Practice Location Reference: Non-primary practice locations
- Endpoint Reference: Healthcare endpoints associated with NPIs
- Taxonomy Reference: Healthcare provider classification codes (NUCC)
Installation
Add this to your Cargo.toml:
[]
= "0.0.3
The CLI binary is called npcli.
Usage
Basic Usage
use *;
// Load main NPPES data
let reader = new;
let providers = reader.load_main_data?;
println!;
// Load taxonomy reference data
let taxonomy_data = reader.load_taxonomy_data?;
Command Line Interface (CLI)
You can use the CLI tool npcli to download, query, and export NPPES data.
Example: Download the latest NPPES data
Example: Show statistics for a dataset
Example: Query providers by state and specialty
Example: Export data to JSON
Analytics and Querying
use *;
// Create analytics engine
let analytics = new
.with_taxonomy_reference;
// Get dataset statistics
let stats = analytics.dataset_stats;
stats.print_summary;
// Find providers by state
let ca_providers = analytics.find_by_state;
println!;
// Find providers by taxonomy code
let physicians = analytics.find_by_taxonomy_code;
println!;
// Complex queries with builder pattern
let query_results = new
.entity_type
.state
.active_only
.execute;
println!;
Working with Individual Records
use *;
// Find a specific provider by NPI
let npi = new?;
if let Some = analytics.find_by_npi
Data Enrichment
use *;
// Enrich providers with human-readable taxonomy descriptions
let enriched_providers = analytics.enrich_with_taxonomy_descriptions?;
for enriched in enriched_providers.iter.take
Advanced Analytics
use *;
// Get top states by provider count
let top_states = analytics.top_states_by_provider_count;
for in top_states
// Get top specialties
let top_specialties = analytics.top_taxonomy_codes_by_provider_count;
for in top_specialties
// Date-based queries
use NaiveDate;
let start_date = from_ymd_opt.unwrap;
let end_date = from_ymd_opt.unwrap;
let new_providers = analytics.providers_enumerated_between;
println!;
Configuration Options
Reader Configuration
use *;
let reader = new
.with_header_validation // Validate CSV headers (default: true)
.with_skip_invalid_records; // Skip invalid records (default: false)
Error Handling
The library uses a comprehensive error system:
use *;
match reader.load_main_data
Data Structures
Core Types
NppesRecord: Main provider record with all NPPES dataEntityType: Individual vs Organization provider typeNpi: Type-safe NPI number wrapperTaxonomyCode: Healthcare specialty/taxonomy informationAddress: Mailing and practice location addresses
Reference Types
TaxonomyReference: Healthcare taxonomy lookup dataOtherNameRecord: Additional organization namesPracticeLocationRecord: Secondary practice locationsEndpointRecord: Healthcare endpoints
Performance Considerations
- The main NPPES file is 9.9GB with ~8M records
- Recommend 16GB+ RAM for full dataset processing
- Use streaming or chunked processing for memory-constrained environments
- Consider creating indexes for frequently queried fields
License
MIT License
Contributing
Contributions welcome! Please see CONTRIBUTING.md for guidelines.