med.icd - Medical Coding
ICD-10-CM code lookup, keyword search, DRG grouping, SNOMED CT mapping, and code validation.
Built-in ICD-10 Database
30+ common clinical codes across these chapters:
| Chapter | Coverage |
|---|---|
| I - Infectious | Sepsis (A41.x), MRSA, bacterial agents |
| IV - Endocrine | Type 1 & 2 DM, DKA, hyperglycemia |
| IX - Circulatory | Hypertension, MI, AFib, heart failure |
| X - Respiratory | Pneumonia, respiratory failure, ARDS |
| XIV - Genitourinary | AKI, ESRD |
| XI - Digestive | Cirrhosis, GI hemorrhage |
| XVIII - Symptoms | Severe sepsis, septic shock, hypovolemic shock |
| XXI - Encounters | Chemotherapy encounters, history codes |
Methods
lookup(code) → dict
Look up an ICD-10-CM code. Returns description, category, chapter, billable status, related codes, and SNOMED CT mapping.
lib.icd.lookup("A41.9")
# {'code': 'A41.9', 'description': 'Sepsis, unspecified organism',
# 'category': 'Septicemia', 'chapter': 'I', 'is_billable': True,
# 'related_codes': ['A41.0', 'A41.1', 'R65.20'], 'snomed_ct': '91302008'}
search(term) → dict
Search codes by keyword in description or category.
lib.icd.search("diabetes")
# {'results': [
# {'code': 'E11.9', 'description': 'Type 2 diabetes mellitus without complications'},
# {'code': 'E11.65', 'description': 'Type 2 DM with hyperglycemia'},
# ...
# ], 'count': 5}
related(code) → dict
Find related ICD-10 codes for a given code.
category(code) → dict
Get the category and chapter for a code.
drg_lookup(diagnosis_codes) → dict
Find potential DRG grouping from a list of diagnosis codes. Returns matching DRGs sorted by weight.
Built-in DRG groups:
| DRG | Name | Weight |
|---|---|---|
| 870 | Septicemia w MV over 96h | 5.44 |
| 871 | Septicemia w/o MV over 96h w MCC | 1.88 |
| 441 | Liver disorders w MCC | 1.93 |
| 280 | Acute MI | 1.44 |
| 291 | Heart failure w MCC | 1.40 |
| 682 | Renal failure w MCC | 1.26 |
| 637 | Diabetes w MCC | 1.20 |
| 193 | Pneumonia w MCC | 1.17 |
lib.icd.drg_lookup(["A41.9", "R65.20"])
# {'primary_drg': {'drg': '870', 'name': 'Septicemia w MV over 96h',
# 'weight': 5.44, 'matching_codes': ['A41.9', 'R65.20']}}
snomed_to_icd(snomed_code) → dict
Map a SNOMED CT concept ID to ICD-10-CM codes.
lib.icd.snomed_to_icd("91302008")
# {'icd10_matches': [{'code': 'A41.9', 'description': 'Sepsis, unspecified'}]}
validate_codes(codes) → dict
Validate a list of ICD-10 codes. Returns valid/invalid status and billable flag for each.
lib.icd.validate_codes(["A41.9", "FAKE.1", "I10"])
# {'valid': 2, 'invalid': 1, 'results': [...]}
list_codes(chapter=None) → list
List all codes, optionally filtered by chapter.
Integration with med.finance
protocol BillingWorkflow {
input: Patient p;
let dx = med.icd.lookup("A41.9");
let drg = med.icd.drg_lookup(["A41.9", "R65.21"]);
med.finance.bill("99291", "Critical Care");
// DRG weight drives reimbursement
}
See Also
- med.fhir — export diagnoses as FHIR Condition resources
- med.finance — CPT billing codes alongside diagnosis codes
- med.lab — lab results supporting diagnosis documentation