ICDMap
A command-line and Python library for converting ICD codes using an offline SQLite database.
Features
- ✅ Offline lookup via included
icd_mapping.dbanddeath_cause_mapping.db - ✅ CLI and Python API support
- ✅ Structured JSON output with Chinese/English descriptions and mapping code
- ✅ Supports ICD-9 → ICD-10 and ICD-10 → ICD-9
- ✅ Auto-detect or manual specification of code type
- ✅ Supports cause-of-death mapping by ICD code or Cause code
Usage
1. CLI
# Single code (auto-detect type)
icdmap 250.00
# Force as ICD-9 input
icdmap 250.00 --source icd9
# Force as ICD-10 input
icdmap I10 --source icd10
# Batch from CSV with column 'ICD9_CODE'
icdmap --csv input.csv -o output.json
# Batch with manual source type
icdmap --csv input.csv --source icd9 -o output.json
# Death cause mapping by ICD-9
icdmap 410 --mode death --source icd9
# Death cause mapping by CSV
icdmap --csv death.csv --mode death -o death_output.json
2. Python API
from icdmap import ICDConverter, DeathCauseMapper
# ICD mapping
mapper = ICDConverter()
mapper.convert("250.00")
mapper.convert(["250.00", "I10"])
# Death cause mapping
death_mapper = DeathCauseMapper()
death_mapper.convert("41401", source="icd9")
death_mapper.convert(["41071", "431"], source="icd9")
3. Batch Mapping with Pandas (and tqdm progress)
import pandas as pd
from icdmap import ICDConverter, DeathCauseMapper
# 建立範例資料(模擬 ICD-9 code)
df = pd.DataFrame({
"ICD9_CODE": ["250.00", "41401", "0389", "431", "41071"]
})
# ICD mapping
icd_mapper = ICDConverter()
icd_results = icd_mapper.convert(df["ICD9_CODE"])
def get_icd_field(code, field):
return icd_results[code][0][field] if icd_results[code] else pd.NA
df["ICD-10"] = df["ICD9_CODE"].map(lambda x: get_icd_field(x, "ICD-10"))
df["ICD-10 English"] = df["ICD9_CODE"].map(lambda x: get_icd_field(x, "ICD-10 English"))
df["ICD-9 English"] = df["ICD9_CODE"].map(lambda x: get_icd_field(x, "ICD-9 English"))
# Death cause mapping
death_mapper = DeathCauseMapper()
death_results = death_mapper.convert(df["ICD9_CODE"], source="icd9")
def get_death_field(code, field):
return death_results[code][0][field] if death_results[code] else "Other causes"
df["CAUSE_CN"] = df["ICD9_CODE"].map(lambda x: get_death_field(x, "Cause_Chinese"))
df["CAUSE_EN"] = df["ICD9_CODE"].map(lambda x: get_death_field(x, "Cause_English"))
LICENSE
MIT License
Copyright (c) 2025
Metadata
Release files for icdmap 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| icdmap-0.1.1.tar.gz | 2.2 MB | Without provenance | Details for icdmap-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| icdmap-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for icdmap-0.1.1-py3-none-any.whl |
Total release size: 4.4 MB
Release files / icdmap-0.1.1.tar.gz
| Download URL | icdmap-0.1.1.tar.gz |
|---|---|
| Size | 2.2 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6c52e81ea331a08eaf3ca37f28cd6b1ae2483ab2438738182be7e9b2c88d44e2
|
|
BLAKE2b-256 checksum How to use checksums |
03d5fc89f6f57db201d82ae14d1146d85dffb36a2d200cfa06b85befdfa96a0b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.9.12
|
Release files / icdmap-0.1.1-py3-none-any.whl
| Download URL | icdmap-0.1.1-py3-none-any.whl |
|---|---|
| Size | 2.2 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
968adae24ced5525aa81b27c1a596c268a7087175be04e44eb60b905fd6b0955
|
|
BLAKE2b-256 checksum How to use checksums |
87a7c4f2481fb87f54585c111f793640174622630a33a80ccd7a4e8cd964a05b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.9.12
|
Security for icdmap 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.