This repository contains a Python script that processes ICD-10 codes and generates a hierarchical description for each code, as well as separate columns for each level of the hierarchy.
The main purpose of this code is to:
- Read ICD-10 codes from a CSV file
- Create a hierarchical description for each code by combining descriptions from all parent codes
- Generate separate columns for each level of the hierarchy
- Save the resulting data to a new CSV file
The code identifies parent-child relationships in ICD-10 codes based on their structure. For example:
- "A01.03" has parents "A01.0", "A01", and "A"
- For each code, it creates a description including all parent descriptions, like: "Typhoid pneumonia -> Typhoid fever -> Typhoid and paratyphoid fevers"
- Place your ICD-10 code CSV file in the same directory as the script
- Ensure your CSV file has at least the following columns:
CodeWithSeparator
(e.g., "A01.0")ShortDescription
(e.g., "Typhoid fever")
- Run the script:
python icd10_hierarchy_processor.py
- The script will create a new file called
icd_codes_with_hierarchy_description.csv
which includes:- All original columns
- A new column
icd10_hierarchy_description
with the complete hierarchy - Multiple columns
ShortDescription_n_1
,ShortDescription_n_2
, etc. with individual hierarchy levels
- Python 3.x
- pandas library