Skip to main content

Official Python SDK for the AutoICD API — clinical text to ICD-10-CM and ICD-11 diagnosis codes, powered by AI and medical NLP. Includes ICD-10/ICD-11 crosswalk.

Project description

AutoICD API — Python SDK

PyPI version License: MIT Python

Official Python SDK for the AutoICD API — clinical text to ICD-10-CM and ICD-11 diagnosis codes, powered by AI and medical NLP.

Single dependency (httpx). Works in Python 3.10+.

Built for EHR integrations, health-tech platforms, medical billing, clinical decision support, and revenue cycle management.


Why AutoICD API

AI-Powered ICD-10 & ICD-11 Coding Clinical NLP extracts diagnoses from free-text notes and maps them to ICD-10-CM or ICD-11 codes — no manual lookup required
74,000+ ICD-10-CM Codes Full 2025 code set enriched with SNOMED CT synonyms for comprehensive matching
ICD-11 Support Search and look up ICD-11 codes, with full ICD-10 ↔ ICD-11 crosswalk mappings
Negation & Context Detection Knows the difference between "patient has diabetes" and "patient denies diabetes" — flags negated, historical, uncertain, and family-history mentions
PHI De-identification HIPAA-compliant anonymization of names, dates, SSNs, phone numbers, emails, addresses, MRNs, and ages
Confidence Scoring Every code match includes a similarity score and confidence level so you can set your own acceptance thresholds
Spell Correction Handles misspellings in clinical text — "diabeties" still maps to the right code
Fully Typed Complete type annotations for all requests and responses

Install

pip install autoicd
uv / poetry / pdm
uv add autoicd
poetry add autoicd
pdm add autoicd

Quick Start

from autoicd import AutoICD

client = AutoICD(api_key="sk_...")

result = client.code(
    "Patient has type 2 diabetes and essential hypertension"
)

for entity in result.entities:
    print(entity.entity_text, "→", entity.codes[0].code)
# "type 2 diabetes"       → "E11.9"
# "essential hypertension" → "I10"

Features

Automated ICD-10 Medical Coding

Extract diagnosis entities from clinical notes and map them to ICD-10-CM codes. Each entity includes ranked candidates with confidence scores, negation status, and context flags.

result = client.code(
    "History of severe COPD with acute exacerbation. Patient denies chest pain."
)

for entity in result.entities:
    print(entity.entity_text)
    print(f"  Negated: {entity.negated}")
    print(f"  Historical: {entity.historical}")
    for match in entity.codes:
        print(
            f"  {match.code}{match.description} "
            f"({match.confidence}, {match.similarity * 100:.1f}%)"
        )

Fine-tune results with coding options:

from autoicd import CodeOptions

result = client.code(
    "Patient presents with acute bronchitis and chest pain",
    options=CodeOptions(
        top_k=3,               # Top 3 ICD-10 candidates per entity (default: 5)
        include_negated=False, # Exclude negated conditions from results
    ),
)

ICD-10 Code Search

Search the full ICD-10-CM 2025 code set by description. Perfect for building code lookup UIs, autocomplete fields, and validation workflows.

results = client.icd10.search("diabetes mellitus")
# results.codes → [CodeDetail(code="E11.9", short_description="...", ...), ...]

from autoicd import SearchOptions
results = client.icd10.search("heart failure", options=SearchOptions(limit=5))

ICD-10 Code Details

Get full details for any ICD-10-CM code — descriptions, billable status, synonyms, hierarchy, and chapter classification.

detail = client.icd10.get("E11.9")
print(detail.code)              # "E11.9"
print(detail.long_description)  # "Type 2 diabetes mellitus without complications"
print(detail.is_billable)       # True
print(detail.synonyms["snomed"])  # ["Diabetes mellitus type 2", ...]
print(detail.chapter.title)       # "Endocrine, Nutritional and Metabolic Diseases"

ICD-11 Code Search

Search the ICD-11 code set by description. The AutoICD API includes the full WHO ICD-11 MMS hierarchy.

results = client.icd11.search("diabetes mellitus")
# results.codes → [ICD11CodeSearchResult(code="5A11", short_description="...", ...), ...]

results = client.icd11.search("heart failure", options=SearchOptions(limit=5))

ICD-11 Code Details & Crosswalk

Get full details for any ICD-11 code — descriptions, Foundation URI, hierarchy, synonyms, and ICD-10 crosswalk mappings.

detail = client.icd11.get("5A11")
print(detail.code)              # "5A11"
print(detail.short_description) # "Type 2 diabetes mellitus"
print(detail.foundation_uri)    # "http://id.who.int/icd/entity/1691003785"
print(detail.chapter.title)     # "Endocrine, nutritional or metabolic diseases"

# ICD-10 crosswalk
for mapping in detail.icd10_mappings:
    print(f"{mapping.code}{mapping.description} ({mapping.mapping_type})")
    # "E11.9 — Type 2 diabetes mellitus without complications (equivalent)"

ICD-10 → ICD-11 Crosswalk

ICD-10 code details now include ICD-11 crosswalk mappings when available:

detail = client.icd10.get("E11.9")
for mapping in detail.icd11_mappings:
    print(f"{mapping.code}{mapping.description}")
    # "5A11 — Type 2 diabetes mellitus"

PHI De-identification

Strip protected health information from clinical notes before storage or analysis. HIPAA-compliant de-identification for names, dates, SSNs, phone numbers, emails, addresses, MRNs, and ages.

result = client.anonymize(
    "John Smith, DOB 01/15/1980, MRN 123456, has COPD"
)

print(result.anonymized_text)
# "[NAME], DOB [DATE], MRN [MRN], has COPD"

print(result.pii_count)     # 3
print(result.pii_entities)  # [PIIEntity(text="John Smith", label="NAME", ...), ...]

Common ICD-10 Codes

The SDK can code any of the 74,000+ ICD-10-CM codes. Here are some of the most commonly coded conditions:

Condition ICD-10 Code Description
Hypertension I10 Essential (primary) hypertension
Type 2 Diabetes E11.9 Type 2 diabetes mellitus without complications
Depression F32.9 Major depressive disorder, single episode, unspecified
Anxiety F41.1 Generalized anxiety disorder
Low Back Pain M54.5 Low back pain
COPD J44.9 Chronic obstructive pulmonary disease, unspecified
Heart Failure I50.9 Heart failure, unspecified
UTI N39.0 Urinary tract infection, site not specified
Pneumonia J18.9 Pneumonia, unspecified organism
Atrial Fibrillation I48.91 Unspecified atrial fibrillation
Obesity E66.01 Morbid (severe) obesity due to excess calories
GERD K21.9 Gastro-esophageal reflux disease without esophagitis
Hypothyroidism E03.9 Hypothyroidism, unspecified
CKD N18.9 Chronic kidney disease, unspecified

Browse all 74,000+ codes in the ICD-10-CM Code Directory or find codes by condition.


Use Cases

  • EHR / EMR Integration — Auto-code clinical notes as providers type, reducing manual coding burden
  • Medical Billing & RCM — Accelerate claim submission with accurate ICD-10 codes
  • Clinical Decision Support — Map patient conditions to standardized codes for analytics and alerts
  • Health-Tech SaaS — Add ICD-10 coding to your platform without building ML infrastructure
  • Clinical Research — Extract and standardize diagnoses from unstructured medical records
  • Insurance & Payer Systems — Validate and suggest diagnosis codes during claims processing
  • Telehealth Platforms — Generate diagnosis codes from visit notes and transcriptions

Error Handling

from autoicd import (
    AutoICD,
    AuthenticationError,
    RateLimitError,
    NotFoundError,
)

try:
    result = client.code("...")
except AuthenticationError:
    # Invalid or revoked API key (401)
    ...
except RateLimitError as e:
    # Request limit exceeded (429)
    print(e.rate_limit.remaining, e.rate_limit.reset_at)
except NotFoundError:
    # ICD-10 code not found (404)
    ...

Rate limit info is available after every request:

client.code("...")
print(client.last_rate_limit)
# RateLimit(limit=1000, remaining=987, reset_at=datetime(...))

Configuration

client = AutoICD(
    api_key="sk_...",                   # Required — get yours at https://autoicdapi.com
    base_url="https://...",             # Default: https://autoicdapi.com
    timeout=60.0,                       # Default: 30.0 seconds
    http_client=httpx.Client(...),      # Custom httpx client (for proxies, mTLS, etc.)
)

Use as a context manager for automatic cleanup:

with AutoICD(api_key="sk_...") as client:
    result = client.code("Patient has diabetes")

API Reference

Full REST API documentation at autoicdapi.com/docs.

Method Description
client.code(text, options?) Code clinical text to ICD-10-CM diagnoses
client.anonymize(text) De-identify PHI/PII in clinical text
client.icd10.search(query, options?) Search ICD-10-CM codes by description
client.icd10.get(code) Get details for an ICD-10-CM code (incl. ICD-11 crosswalk)
client.icd11.search(query, options?) Search ICD-11 codes by description
client.icd11.get(code) Get details for an ICD-11 code (incl. ICD-10 crosswalk)

Types

All request and response types are exported:

from autoicd import (
    CodingResponse,
    CodingEntity,
    CodeMatch,
    CodeOptions,
    CodeDetail,
    CodeSearchResponse,
    AnonymizeResponse,
    PIIEntity,
    RateLimit,
    SearchOptions,
    ICD11CodeDetail,
    ICD11CodeDetailFull,
    ICD11CodeSearchResponse,
    CrosswalkMapping,
)

Requirements


Links


License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

autoicd-0.6.0.tar.gz (28.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

autoicd-0.6.0-py3-none-any.whl (12.6 kB view details)

Uploaded Python 3

File details

Details for the file autoicd-0.6.0.tar.gz.

File metadata

  • Download URL: autoicd-0.6.0.tar.gz
  • Upload date:
  • Size: 28.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.7

File hashes

Hashes for autoicd-0.6.0.tar.gz
Algorithm Hash digest
SHA256 b1483e6e4b7ccb79fb75f77dcd8faa3e6c735fa09c60886d17de878ffdd0819a
MD5 421e4929317eaddafb6de1034a98b3b9
BLAKE2b-256 6f0688ac5ebe1bb95755300ff6e3c78902e8550a25ed1e88326ffbd52394f2c3

See more details on using hashes here.

File details

Details for the file autoicd-0.6.0-py3-none-any.whl.

File metadata

  • Download URL: autoicd-0.6.0-py3-none-any.whl
  • Upload date:
  • Size: 12.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.7

File hashes

Hashes for autoicd-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 37405213e6f6e8f5c7719949e877a16715aec90158782cfdcbf1c690158988a4
MD5 9d9769e215674da3e58d114b46c2bd26
BLAKE2b-256 61319704ed8b6a16fcc59ef4bad35306e216b54b356814387b7e843deeeab68e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page