How stefanotrv/simple_icd_10_cm works
Project Type and Purpose
• Type: Stand-alone Python library / CLI tool
• Purpose: Load ICD-10-CM classification data (XML + TXT), build an in-memory classification tree, and expose helper functions (e.g., is_valid_item, get_ancestors, get_full_data, etc.).
• Key indicators:
– simple_icd_10_cm.py as the single-file source version
– data/ directory with raw ICD files
– package-files/ containing setup.py, build/, dist/ for pip/conda distribution
– A test script test_simple_icd_10_cm.py and a Jupyter notebook for demos
File Structure
Top level:
• .gitattributes, LICENSE, README.md, Instructional Notations.md, _config.yml
• data/
– raw data: icd10cm-order-Jan-2021.txt, icd10cm_tabular_2021.xml
• simple_icd_10_cm.py (single-file entry point alternative)
• test_simple_icd_10_cm.py (unit tests)
• Showcase notebook.ipynb (demo)
• package-files/ (distribution scaffolding)
– setup.py, built artifacts, source tree under simple_icd_10_CM/
README for Additional Insights
• No external services or databases—everything is file-based.
• Core functionality: load data, build classification tree, offer tree-traversal and metadata lookups.
• Packaging: supports pip/conda install, or raw-file usage.
Main Components & Interactions
a. Data Layer
– Raw Data Files (XML + TXT) stored under data/
– Data Loader code in simple_icd_10_cm.py (and its package equivalent) that parses XML, reads TXT, and constructs in-memory structures (nodes for chapters, blocks, categories, subcategories)
b. Core Logic / API Layer
– Classification Tree: internal representation (e.g., dictionaries or objects linking parent/child relationships)
– API Functions: all functions listed in README (is_valid_item(), get_children(), get_full_data(), etc.) that operate on the in-memory model
c. Test & Demo
– Unit Tests in test_simple_icd_10_cm.py exercising the API
– Showcase Notebook for interactive demonstration
d. Packaging / Distribution
– package-files/setup.py configures build
– build/ and dist/ directories containing .whl and .tar.gz artifacts
– Publishing: pip install simple-icd-10-cm or conda install -c stefanotrv simple_icd_10_cm
e. Consumer / Runtime Environment
– A Python interpreter (py3)
– Optionally Jupyter (for the notebook)
– execute_unit_test.cmd on Windows to run tests
Architectural Patterns & Principles
• Single-process in-memory model—no external services
• Module + Data separation—clear boundary between raw data files and code that loads them
• API-first design—all functionality exposed through well-named functions
• Packaging pipeline—source package → build → distribution
Essential Elements
• Clear component labels: Data files, Parser, In-memory model, API functions, Tests, Notebook, Packaging