autoicd 0.4.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,13 @@
1
+ __pycache__/
2
+ *.py[cod]
3
+ *.egg-info/
4
+ dist/
5
+ build/
6
+ .eggs/
7
+ *.egg
8
+ .venv/
9
+ venv/
10
+ .env
11
+ .ruff_cache/
12
+ .pytest_cache/
13
+ .mypy_cache/
@@ -0,0 +1,84 @@
1
+ # AutoICD Python SDK
2
+
3
+ Public SDK for **AutoICD API** (autoicdapi.com). Published as `autoicd` on PyPI.
4
+ GitHub: `github.com/fcggamou/autoicd-python`
5
+
6
+ ## Quick Reference
7
+
8
+ ```bash
9
+ pip install -e ".[dev]" # Install in dev mode with test deps
10
+ pytest # Run tests
11
+ ruff check src/ tests/ # Lint
12
+ ruff format src/ tests/ # Format
13
+ ```
14
+
15
+ ## Architecture
16
+
17
+ ```
18
+ src/autoicd/
19
+ ├── __init__.py — Public exports (re-exports client, types, errors)
20
+ ├── client.py — AutoICD class + Codes sub-resource + HTTP internals
21
+ ├── types.py — All request/response dataclasses
22
+ └── errors.py — AutoICDError hierarchy (401, 404, 429)
23
+ tests/
24
+ └── test_client.py — Unit tests with mocked httpx transport
25
+ ```
26
+
27
+ - **Single dependency** — `httpx` for HTTP (timeout, headers, mock transport for tests)
28
+ - Uses `src/` layout with hatchling build backend
29
+ - Target: Python 3.10+
30
+ - All types are dataclasses — no Pydantic dependency
31
+
32
+ ## API Surface
33
+
34
+ ```python
35
+ client = AutoICD(api_key="sk_...")
36
+
37
+ client.code(text, options?) # POST /api/v1/code — clinical text → ICD-10 codes
38
+ client.anonymize(text) # POST /api/v1/anonymize — PHI de-identification
39
+ client.codes.search(query, opts?) # GET /api/v1/codes/search — search ICD-10 codes
40
+ client.codes.get(code) # GET /api/v1/codes/:code — code details
41
+ client.last_rate_limit # Rate limit info from last response
42
+ ```
43
+
44
+ ## Conventions
45
+
46
+ - All names use **snake_case** (Python convention matches API response format)
47
+ - Options are passed as dataclass instances (e.g., `CodeOptions(top_k=3)`)
48
+ - `None` option values are stripped from request bodies before sending
49
+ - API responses use **snake_case** — dataclasses mirror the raw API shapes, no transformation
50
+ - Error classes: `AutoICDError` (base), `AuthenticationError` (401), `NotFoundError` (404), `RateLimitError` (429)
51
+ - Rate limit headers: `X-RateLimit-Limit`, `X-RateLimit-Remaining`, `X-RateLimit-Reset`
52
+ - API keys start with `sk_`
53
+ - Base URL defaults to `https://autoicdapi.com`, no trailing slash
54
+ - All HTTP goes through the private `_request()` method — single place for auth, timeout, error handling, rate limit parsing
55
+ - Client supports context manager (`with AutoICD(...) as client:`)
56
+
57
+ ## This Is a Marketing Asset
58
+
59
+ The README, pyproject.toml description, and keywords are **SEO-optimized** to drive traffic to autoicdapi.com. When editing:
60
+
61
+ - Keep the README rich with examples, use cases, and links back to autoicdapi.com
62
+ - Maintain keyword density in pyproject.toml (icd-10, medical-coding, clinical-nlp, etc.)
63
+ - Use real-looking clinical examples in code samples (they appear in search results)
64
+ - Brand name is **AutoICD API** — always capitalize correctly
65
+
66
+ ## Git Identity
67
+
68
+ This is a **public repo**. All commits MUST be authored by the AutoICD brand — never use personal or work identities.
69
+
70
+ Before committing, always use repo-local git config:
71
+ ```bash
72
+ git -C /Users/fede/repos/autoicd/sdk-py commit --author="AutoICD <info@autoicdapi.com>"
73
+ ```
74
+
75
+ If creating commits via the CLI, always pass `--author="AutoICD <info@autoicdapi.com>"`.
76
+
77
+ ## Sync with API
78
+
79
+ The SDK calls the Next.js API routes at `api/src/app/api/v1/`. Any changes to API request/response shapes must be reflected here:
80
+
81
+ - Route changes → update paths in `client.py`
82
+ - Response shape changes → update dataclasses in `types.py`
83
+ - New endpoints → add method to `AutoICD` or `Codes` class, export types from `__init__.py`
84
+ - Test against live API or local dev server (port 3000) with `base_url="http://localhost:3000"`
autoicd-0.4.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Fede
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
autoicd-0.4.0/PKG-INFO ADDED
@@ -0,0 +1,293 @@
1
+ Metadata-Version: 2.4
2
+ Name: autoicd
3
+ Version: 0.4.0
4
+ Summary: Official Python SDK for the AutoICD API — clinical text to ICD-10-CM diagnosis codes, powered by AI and medical NLP
5
+ Project-URL: Homepage, https://autoicdapi.com
6
+ Project-URL: Documentation, https://autoicdapi.com/docs
7
+ Project-URL: Repository, https://github.com/fcggamou/autoicd-python
8
+ Project-URL: Issues, https://github.com/fcggamou/autoicd-python/issues
9
+ Author-email: AutoICD <info@autoicdapi.com>
10
+ License-Expression: MIT
11
+ License-File: LICENSE
12
+ Keywords: autoicd,clinical-decision-support,clinical-nlp,diagnosis-codes,ehr,emr,health-tech,hipaa,icd-10,icd-10-cm,medical-billing,medical-coding,medical-nlp,phi-deidentification,revenue-cycle-management
13
+ Classifier: Development Status :: 4 - Beta
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Intended Audience :: Healthcare Industry
16
+ Classifier: License :: OSI Approved :: MIT License
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Programming Language :: Python :: 3.13
22
+ Classifier: Topic :: Scientific/Engineering :: Medical Science Apps.
23
+ Classifier: Typing :: Typed
24
+ Requires-Python: >=3.10
25
+ Requires-Dist: httpx>=0.27
26
+ Provides-Extra: dev
27
+ Requires-Dist: pytest>=8.0; extra == 'dev'
28
+ Requires-Dist: ruff>=0.5; extra == 'dev'
29
+ Description-Content-Type: text/markdown
30
+
31
+ # AutoICD API — Python SDK
32
+
33
+ [![PyPI version](https://img.shields.io/pypi/v/autoicd.svg)](https://pypi.org/project/autoicd/)
34
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
35
+ [![Python](https://img.shields.io/badge/Python-3.10+-blue.svg)](https://www.python.org/)
36
+
37
+ Official Python SDK for the [AutoICD API](https://autoicdapi.com) — clinical text to ICD-10-CM diagnosis codes, powered by AI and medical NLP.
38
+
39
+ Single dependency (`httpx`). Works in **Python 3.10+**.
40
+
41
+ > Built for EHR integrations, health-tech platforms, medical billing, clinical decision support, and revenue cycle management.
42
+
43
+ ---
44
+
45
+ ## Why AutoICD API
46
+
47
+ | | |
48
+ |---|---|
49
+ | **AI-Powered ICD-10 Coding** | Clinical NLP extracts diagnoses from free-text notes and maps them to ICD-10-CM codes — no manual lookup required |
50
+ | **74,000+ ICD-10-CM Codes** | Full 2025 code set enriched with SNOMED CT synonyms for comprehensive matching |
51
+ | **Negation & Context Detection** | Knows the difference between "patient has diabetes" and "patient denies diabetes" — flags negated, historical, uncertain, and family-history mentions |
52
+ | **PHI De-identification** | HIPAA-compliant anonymization of names, dates, SSNs, phone numbers, emails, addresses, MRNs, and ages |
53
+ | **Confidence Scoring** | Every code match includes a similarity score and confidence level so you can set your own acceptance thresholds |
54
+ | **Spell Correction** | Handles misspellings in clinical text — "diabeties" still maps to the right code |
55
+ | **Fully Typed** | Complete type annotations for all requests and responses |
56
+
57
+ ---
58
+
59
+ ## Install
60
+
61
+ ```bash
62
+ pip install autoicd
63
+ ```
64
+
65
+ <details>
66
+ <summary>uv / poetry / pdm</summary>
67
+
68
+ ```bash
69
+ uv add autoicd
70
+ poetry add autoicd
71
+ pdm add autoicd
72
+ ```
73
+
74
+ </details>
75
+
76
+ ---
77
+
78
+ ## Quick Start
79
+
80
+ ```python
81
+ from autoicd import AutoICD
82
+
83
+ client = AutoICD(api_key="sk_...")
84
+
85
+ result = client.code(
86
+ "Patient has type 2 diabetes and essential hypertension"
87
+ )
88
+
89
+ for entity in result.entities:
90
+ print(entity.entity_text, "→", entity.codes[0].code)
91
+ # "type 2 diabetes" → "E11.9"
92
+ # "essential hypertension" → "I10"
93
+ ```
94
+
95
+ ---
96
+
97
+ ## Features
98
+
99
+ ### Automated ICD-10 Medical Coding
100
+
101
+ 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.
102
+
103
+ ```python
104
+ result = client.code(
105
+ "History of severe COPD with acute exacerbation. Patient denies chest pain."
106
+ )
107
+
108
+ for entity in result.entities:
109
+ print(entity.entity_text)
110
+ print(f" Negated: {entity.negated}")
111
+ print(f" Historical: {entity.historical}")
112
+ for match in entity.codes:
113
+ print(
114
+ f" {match.code} — {match.description} "
115
+ f"({match.confidence}, {match.similarity * 100:.1f}%)"
116
+ )
117
+ ```
118
+
119
+ Fine-tune results with coding options:
120
+
121
+ ```python
122
+ from autoicd import CodeOptions
123
+
124
+ result = client.code(
125
+ "Patient presents with acute bronchitis and chest pain",
126
+ options=CodeOptions(
127
+ top_k=3, # Top 3 ICD-10 candidates per entity (default: 5)
128
+ include_negated=False, # Exclude negated conditions from results
129
+ ),
130
+ )
131
+ ```
132
+
133
+ ### ICD-10 Code Search
134
+
135
+ Search the full ICD-10-CM 2025 code set by description. Perfect for building code lookup UIs, autocomplete fields, and validation workflows.
136
+
137
+ ```python
138
+ results = client.codes.search("diabetes mellitus")
139
+ # results.codes → [CodeDetail(code="E11.9", short_description="...", ...), ...]
140
+
141
+ from autoicd import SearchOptions
142
+ results = client.codes.search("heart failure", options=SearchOptions(limit=5))
143
+ ```
144
+
145
+ ### ICD-10 Code Details
146
+
147
+ Get full details for any ICD-10-CM code — descriptions, billable status, synonyms, hierarchy, and chapter classification.
148
+
149
+ ```python
150
+ detail = client.codes.get("E11.9")
151
+ print(detail.code) # "E11.9"
152
+ print(detail.long_description) # "Type 2 diabetes mellitus without complications"
153
+ print(detail.is_billable) # True
154
+ print(detail.synonyms["snomed"]) # ["Diabetes mellitus type 2", ...]
155
+ print(detail.chapter.title) # "Endocrine, Nutritional and Metabolic Diseases"
156
+ ```
157
+
158
+ ### PHI De-identification
159
+
160
+ 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.
161
+
162
+ ```python
163
+ result = client.anonymize(
164
+ "John Smith, DOB 01/15/1980, MRN 123456, has COPD"
165
+ )
166
+
167
+ print(result.anonymized_text)
168
+ # "[NAME], DOB [DATE], MRN [MRN], has COPD"
169
+
170
+ print(result.pii_count) # 3
171
+ print(result.pii_entities) # [PIIEntity(text="John Smith", label="NAME", ...), ...]
172
+ ```
173
+
174
+ ---
175
+
176
+ ## Use Cases
177
+
178
+ - **EHR / EMR Integration** — Auto-code clinical notes as providers type, reducing manual coding burden
179
+ - **Medical Billing & RCM** — Accelerate claim submission with accurate ICD-10 codes
180
+ - **Clinical Decision Support** — Map patient conditions to standardized codes for analytics and alerts
181
+ - **Health-Tech SaaS** — Add ICD-10 coding to your platform without building ML infrastructure
182
+ - **Clinical Research** — Extract and standardize diagnoses from unstructured medical records
183
+ - **Insurance & Payer Systems** — Validate and suggest diagnosis codes during claims processing
184
+ - **Telehealth Platforms** — Generate diagnosis codes from visit notes and transcriptions
185
+
186
+ ---
187
+
188
+ ## Error Handling
189
+
190
+ ```python
191
+ from autoicd import (
192
+ AutoICD,
193
+ AuthenticationError,
194
+ RateLimitError,
195
+ NotFoundError,
196
+ )
197
+
198
+ try:
199
+ result = client.code("...")
200
+ except AuthenticationError:
201
+ # Invalid or revoked API key (401)
202
+ ...
203
+ except RateLimitError as e:
204
+ # Request limit exceeded (429)
205
+ print(e.rate_limit.remaining, e.rate_limit.reset_at)
206
+ except NotFoundError:
207
+ # ICD-10 code not found (404)
208
+ ...
209
+ ```
210
+
211
+ Rate limit info is available after every request:
212
+
213
+ ```python
214
+ client.code("...")
215
+ print(client.last_rate_limit)
216
+ # RateLimit(limit=1000, remaining=987, reset_at=datetime(...))
217
+ ```
218
+
219
+ ---
220
+
221
+ ## Configuration
222
+
223
+ ```python
224
+ client = AutoICD(
225
+ api_key="sk_...", # Required — get yours at https://autoicdapi.com
226
+ base_url="https://...", # Default: https://autoicdapi.com
227
+ timeout=60.0, # Default: 30.0 seconds
228
+ http_client=httpx.Client(...), # Custom httpx client (for proxies, mTLS, etc.)
229
+ )
230
+ ```
231
+
232
+ Use as a context manager for automatic cleanup:
233
+
234
+ ```python
235
+ with AutoICD(api_key="sk_...") as client:
236
+ result = client.code("Patient has diabetes")
237
+ ```
238
+
239
+ ---
240
+
241
+ ## API Reference
242
+
243
+ Full REST API documentation at [autoicdapi.com/docs](https://autoicdapi.com/docs).
244
+
245
+ | Method | Description |
246
+ |--------|-------------|
247
+ | `client.code(text, options?)` | Code clinical text to ICD-10-CM diagnoses |
248
+ | `client.anonymize(text)` | De-identify PHI/PII in clinical text |
249
+ | `client.codes.search(query, options?)` | Search ICD-10-CM codes by description |
250
+ | `client.codes.get(code)` | Get details for an ICD-10-CM code |
251
+
252
+ ---
253
+
254
+ ## Types
255
+
256
+ All request and response types are exported:
257
+
258
+ ```python
259
+ from autoicd import (
260
+ CodingResponse,
261
+ CodingEntity,
262
+ CodeMatch,
263
+ CodeOptions,
264
+ CodeDetail,
265
+ CodeSearchResponse,
266
+ AnonymizeResponse,
267
+ PIIEntity,
268
+ RateLimit,
269
+ SearchOptions,
270
+ )
271
+ ```
272
+
273
+ ---
274
+
275
+ ## Requirements
276
+
277
+ - **Python 3.10+**
278
+ - An API key from [autoicdapi.com](https://autoicdapi.com)
279
+
280
+ ---
281
+
282
+ ## Links
283
+
284
+ - [AutoICD API](https://autoicdapi.com) — Homepage and API key management
285
+ - [API Documentation](https://autoicdapi.com/docs) — Full REST API reference
286
+ - [TypeScript SDK](https://www.npmjs.com/package/autoicd) — `npm install autoicd`
287
+ - [ICD-10-CM 2025 Code Set](https://www.cms.gov/medicare/coding-billing/icd-10-codes) — Official CMS reference
288
+
289
+ ---
290
+
291
+ ## License
292
+
293
+ MIT
@@ -0,0 +1,263 @@
1
+ # AutoICD API — Python SDK
2
+
3
+ [![PyPI version](https://img.shields.io/pypi/v/autoicd.svg)](https://pypi.org/project/autoicd/)
4
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
5
+ [![Python](https://img.shields.io/badge/Python-3.10+-blue.svg)](https://www.python.org/)
6
+
7
+ Official Python SDK for the [AutoICD API](https://autoicdapi.com) — clinical text to ICD-10-CM diagnosis codes, powered by AI and medical NLP.
8
+
9
+ Single dependency (`httpx`). Works in **Python 3.10+**.
10
+
11
+ > Built for EHR integrations, health-tech platforms, medical billing, clinical decision support, and revenue cycle management.
12
+
13
+ ---
14
+
15
+ ## Why AutoICD API
16
+
17
+ | | |
18
+ |---|---|
19
+ | **AI-Powered ICD-10 Coding** | Clinical NLP extracts diagnoses from free-text notes and maps them to ICD-10-CM codes — no manual lookup required |
20
+ | **74,000+ ICD-10-CM Codes** | Full 2025 code set enriched with SNOMED CT synonyms for comprehensive matching |
21
+ | **Negation & Context Detection** | Knows the difference between "patient has diabetes" and "patient denies diabetes" — flags negated, historical, uncertain, and family-history mentions |
22
+ | **PHI De-identification** | HIPAA-compliant anonymization of names, dates, SSNs, phone numbers, emails, addresses, MRNs, and ages |
23
+ | **Confidence Scoring** | Every code match includes a similarity score and confidence level so you can set your own acceptance thresholds |
24
+ | **Spell Correction** | Handles misspellings in clinical text — "diabeties" still maps to the right code |
25
+ | **Fully Typed** | Complete type annotations for all requests and responses |
26
+
27
+ ---
28
+
29
+ ## Install
30
+
31
+ ```bash
32
+ pip install autoicd
33
+ ```
34
+
35
+ <details>
36
+ <summary>uv / poetry / pdm</summary>
37
+
38
+ ```bash
39
+ uv add autoicd
40
+ poetry add autoicd
41
+ pdm add autoicd
42
+ ```
43
+
44
+ </details>
45
+
46
+ ---
47
+
48
+ ## Quick Start
49
+
50
+ ```python
51
+ from autoicd import AutoICD
52
+
53
+ client = AutoICD(api_key="sk_...")
54
+
55
+ result = client.code(
56
+ "Patient has type 2 diabetes and essential hypertension"
57
+ )
58
+
59
+ for entity in result.entities:
60
+ print(entity.entity_text, "→", entity.codes[0].code)
61
+ # "type 2 diabetes" → "E11.9"
62
+ # "essential hypertension" → "I10"
63
+ ```
64
+
65
+ ---
66
+
67
+ ## Features
68
+
69
+ ### Automated ICD-10 Medical Coding
70
+
71
+ 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.
72
+
73
+ ```python
74
+ result = client.code(
75
+ "History of severe COPD with acute exacerbation. Patient denies chest pain."
76
+ )
77
+
78
+ for entity in result.entities:
79
+ print(entity.entity_text)
80
+ print(f" Negated: {entity.negated}")
81
+ print(f" Historical: {entity.historical}")
82
+ for match in entity.codes:
83
+ print(
84
+ f" {match.code} — {match.description} "
85
+ f"({match.confidence}, {match.similarity * 100:.1f}%)"
86
+ )
87
+ ```
88
+
89
+ Fine-tune results with coding options:
90
+
91
+ ```python
92
+ from autoicd import CodeOptions
93
+
94
+ result = client.code(
95
+ "Patient presents with acute bronchitis and chest pain",
96
+ options=CodeOptions(
97
+ top_k=3, # Top 3 ICD-10 candidates per entity (default: 5)
98
+ include_negated=False, # Exclude negated conditions from results
99
+ ),
100
+ )
101
+ ```
102
+
103
+ ### ICD-10 Code Search
104
+
105
+ Search the full ICD-10-CM 2025 code set by description. Perfect for building code lookup UIs, autocomplete fields, and validation workflows.
106
+
107
+ ```python
108
+ results = client.codes.search("diabetes mellitus")
109
+ # results.codes → [CodeDetail(code="E11.9", short_description="...", ...), ...]
110
+
111
+ from autoicd import SearchOptions
112
+ results = client.codes.search("heart failure", options=SearchOptions(limit=5))
113
+ ```
114
+
115
+ ### ICD-10 Code Details
116
+
117
+ Get full details for any ICD-10-CM code — descriptions, billable status, synonyms, hierarchy, and chapter classification.
118
+
119
+ ```python
120
+ detail = client.codes.get("E11.9")
121
+ print(detail.code) # "E11.9"
122
+ print(detail.long_description) # "Type 2 diabetes mellitus without complications"
123
+ print(detail.is_billable) # True
124
+ print(detail.synonyms["snomed"]) # ["Diabetes mellitus type 2", ...]
125
+ print(detail.chapter.title) # "Endocrine, Nutritional and Metabolic Diseases"
126
+ ```
127
+
128
+ ### PHI De-identification
129
+
130
+ 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.
131
+
132
+ ```python
133
+ result = client.anonymize(
134
+ "John Smith, DOB 01/15/1980, MRN 123456, has COPD"
135
+ )
136
+
137
+ print(result.anonymized_text)
138
+ # "[NAME], DOB [DATE], MRN [MRN], has COPD"
139
+
140
+ print(result.pii_count) # 3
141
+ print(result.pii_entities) # [PIIEntity(text="John Smith", label="NAME", ...), ...]
142
+ ```
143
+
144
+ ---
145
+
146
+ ## Use Cases
147
+
148
+ - **EHR / EMR Integration** — Auto-code clinical notes as providers type, reducing manual coding burden
149
+ - **Medical Billing & RCM** — Accelerate claim submission with accurate ICD-10 codes
150
+ - **Clinical Decision Support** — Map patient conditions to standardized codes for analytics and alerts
151
+ - **Health-Tech SaaS** — Add ICD-10 coding to your platform without building ML infrastructure
152
+ - **Clinical Research** — Extract and standardize diagnoses from unstructured medical records
153
+ - **Insurance & Payer Systems** — Validate and suggest diagnosis codes during claims processing
154
+ - **Telehealth Platforms** — Generate diagnosis codes from visit notes and transcriptions
155
+
156
+ ---
157
+
158
+ ## Error Handling
159
+
160
+ ```python
161
+ from autoicd import (
162
+ AutoICD,
163
+ AuthenticationError,
164
+ RateLimitError,
165
+ NotFoundError,
166
+ )
167
+
168
+ try:
169
+ result = client.code("...")
170
+ except AuthenticationError:
171
+ # Invalid or revoked API key (401)
172
+ ...
173
+ except RateLimitError as e:
174
+ # Request limit exceeded (429)
175
+ print(e.rate_limit.remaining, e.rate_limit.reset_at)
176
+ except NotFoundError:
177
+ # ICD-10 code not found (404)
178
+ ...
179
+ ```
180
+
181
+ Rate limit info is available after every request:
182
+
183
+ ```python
184
+ client.code("...")
185
+ print(client.last_rate_limit)
186
+ # RateLimit(limit=1000, remaining=987, reset_at=datetime(...))
187
+ ```
188
+
189
+ ---
190
+
191
+ ## Configuration
192
+
193
+ ```python
194
+ client = AutoICD(
195
+ api_key="sk_...", # Required — get yours at https://autoicdapi.com
196
+ base_url="https://...", # Default: https://autoicdapi.com
197
+ timeout=60.0, # Default: 30.0 seconds
198
+ http_client=httpx.Client(...), # Custom httpx client (for proxies, mTLS, etc.)
199
+ )
200
+ ```
201
+
202
+ Use as a context manager for automatic cleanup:
203
+
204
+ ```python
205
+ with AutoICD(api_key="sk_...") as client:
206
+ result = client.code("Patient has diabetes")
207
+ ```
208
+
209
+ ---
210
+
211
+ ## API Reference
212
+
213
+ Full REST API documentation at [autoicdapi.com/docs](https://autoicdapi.com/docs).
214
+
215
+ | Method | Description |
216
+ |--------|-------------|
217
+ | `client.code(text, options?)` | Code clinical text to ICD-10-CM diagnoses |
218
+ | `client.anonymize(text)` | De-identify PHI/PII in clinical text |
219
+ | `client.codes.search(query, options?)` | Search ICD-10-CM codes by description |
220
+ | `client.codes.get(code)` | Get details for an ICD-10-CM code |
221
+
222
+ ---
223
+
224
+ ## Types
225
+
226
+ All request and response types are exported:
227
+
228
+ ```python
229
+ from autoicd import (
230
+ CodingResponse,
231
+ CodingEntity,
232
+ CodeMatch,
233
+ CodeOptions,
234
+ CodeDetail,
235
+ CodeSearchResponse,
236
+ AnonymizeResponse,
237
+ PIIEntity,
238
+ RateLimit,
239
+ SearchOptions,
240
+ )
241
+ ```
242
+
243
+ ---
244
+
245
+ ## Requirements
246
+
247
+ - **Python 3.10+**
248
+ - An API key from [autoicdapi.com](https://autoicdapi.com)
249
+
250
+ ---
251
+
252
+ ## Links
253
+
254
+ - [AutoICD API](https://autoicdapi.com) — Homepage and API key management
255
+ - [API Documentation](https://autoicdapi.com/docs) — Full REST API reference
256
+ - [TypeScript SDK](https://www.npmjs.com/package/autoicd) — `npm install autoicd`
257
+ - [ICD-10-CM 2025 Code Set](https://www.cms.gov/medicare/coding-billing/icd-10-codes) — Official CMS reference
258
+
259
+ ---
260
+
261
+ ## License
262
+
263
+ MIT