autoicd 0.2.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.
Potentially problematic release.
This version of autoicd might be problematic. Click here for more details.
- autoicd-0.2.0/.gitignore +13 -0
- autoicd-0.2.0/CLAUDE.md +85 -0
- autoicd-0.2.0/LICENSE +21 -0
- autoicd-0.2.0/PKG-INFO +307 -0
- autoicd-0.2.0/README.md +277 -0
- autoicd-0.2.0/pyproject.toml +65 -0
- autoicd-0.2.0/src/autoicd/__init__.py +50 -0
- autoicd-0.2.0/src/autoicd/client.py +277 -0
- autoicd-0.2.0/src/autoicd/errors.py +43 -0
- autoicd-0.2.0/src/autoicd/types.py +210 -0
- autoicd-0.2.0/tests/__init__.py +0 -0
- autoicd-0.2.0/tests/test_client.py +347 -0
autoicd-0.2.0/.gitignore
ADDED
autoicd-0.2.0/CLAUDE.md
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
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.codes.terms(code) # GET /api/v1/codes/:code/terms — index terms
|
|
42
|
+
client.last_rate_limit # Rate limit info from last response
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Conventions
|
|
46
|
+
|
|
47
|
+
- All names use **snake_case** (Python convention matches API response format)
|
|
48
|
+
- Options are passed as dataclass instances (e.g., `CodeOptions(top_k=3)`)
|
|
49
|
+
- `None` option values are stripped from request bodies before sending
|
|
50
|
+
- API responses use **snake_case** — dataclasses mirror the raw API shapes, no transformation
|
|
51
|
+
- Error classes: `AutoICDError` (base), `AuthenticationError` (401), `NotFoundError` (404), `RateLimitError` (429)
|
|
52
|
+
- Rate limit headers: `X-RateLimit-Limit`, `X-RateLimit-Remaining`, `X-RateLimit-Reset`
|
|
53
|
+
- API keys start with `sk_`
|
|
54
|
+
- Base URL defaults to `https://autoicdapi.com`, no trailing slash
|
|
55
|
+
- All HTTP goes through the private `_request()` method — single place for auth, timeout, error handling, rate limit parsing
|
|
56
|
+
- Client supports context manager (`with AutoICD(...) as client:`)
|
|
57
|
+
|
|
58
|
+
## This Is a Marketing Asset
|
|
59
|
+
|
|
60
|
+
The README, pyproject.toml description, and keywords are **SEO-optimized** to drive traffic to autoicdapi.com. When editing:
|
|
61
|
+
|
|
62
|
+
- Keep the README rich with examples, use cases, and links back to autoicdapi.com
|
|
63
|
+
- Maintain keyword density in pyproject.toml (icd-10, medical-coding, clinical-nlp, etc.)
|
|
64
|
+
- Use real-looking clinical examples in code samples (they appear in search results)
|
|
65
|
+
- Brand name is **AutoICD API** — always capitalize correctly
|
|
66
|
+
|
|
67
|
+
## Git Identity
|
|
68
|
+
|
|
69
|
+
This is a **public repo**. All commits MUST be authored by the AutoICD brand — never use personal or work identities.
|
|
70
|
+
|
|
71
|
+
Before committing, always use repo-local git config:
|
|
72
|
+
```bash
|
|
73
|
+
git -C /Users/fede/repos/autoicd/sdk-py commit --author="AutoICD <info@autoicdapi.com>"
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
If creating commits via the CLI, always pass `--author="AutoICD <info@autoicdapi.com>"`.
|
|
77
|
+
|
|
78
|
+
## Sync with API
|
|
79
|
+
|
|
80
|
+
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:
|
|
81
|
+
|
|
82
|
+
- Route changes → update paths in `client.py`
|
|
83
|
+
- Response shape changes → update dataclasses in `types.py`
|
|
84
|
+
- New endpoints → add method to `AutoICD` or `Codes` class, export types from `__init__.py`
|
|
85
|
+
- Test against live API or local dev server (port 3000) with `base_url="http://localhost:3000"`
|
autoicd-0.2.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.2.0/PKG-INFO
ADDED
|
@@ -0,0 +1,307 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: autoicd
|
|
3
|
+
Version: 0.2.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
|
+
[](https://pypi.org/project/autoicd/)
|
|
34
|
+
[](https://opensource.org/licenses/MIT)
|
|
35
|
+
[](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
|
+
strategy="merged", # "individual" or "merged" entity strategy
|
|
129
|
+
include_negated=False, # Exclude negated conditions from results
|
|
130
|
+
),
|
|
131
|
+
)
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
### ICD-10 Code Search
|
|
135
|
+
|
|
136
|
+
Search the full ICD-10-CM 2025 code set by description. Perfect for building code lookup UIs, autocomplete fields, and validation workflows.
|
|
137
|
+
|
|
138
|
+
```python
|
|
139
|
+
results = client.codes.search("diabetes mellitus")
|
|
140
|
+
# results.codes → [CodeDetail(code="E11.9", short_description="...", ...), ...]
|
|
141
|
+
|
|
142
|
+
from autoicd import SearchOptions
|
|
143
|
+
results = client.codes.search("heart failure", options=SearchOptions(limit=5))
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
### ICD-10 Code Details
|
|
147
|
+
|
|
148
|
+
Get full details for any ICD-10-CM code — descriptions, billable status, and indexed terms.
|
|
149
|
+
|
|
150
|
+
```python
|
|
151
|
+
detail = client.codes.get("E11.9")
|
|
152
|
+
print(detail.code) # "E11.9"
|
|
153
|
+
print(detail.long_description) # "Type 2 diabetes mellitus without complications"
|
|
154
|
+
print(detail.is_billable) # True
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
### ICD-10 Code Terms & Synonyms
|
|
158
|
+
|
|
159
|
+
Retrieve all indexed terms and synonyms for a code — includes SNOMED CT mappings and clinical variants.
|
|
160
|
+
|
|
161
|
+
```python
|
|
162
|
+
terms = client.codes.terms("E11.9")
|
|
163
|
+
for t in terms:
|
|
164
|
+
print(t.term, f"({t.term_type})")
|
|
165
|
+
# "Type 2 diabetes mellitus without complications" (long_desc)
|
|
166
|
+
# "adult onset diabetes" (synonym)
|
|
167
|
+
# ...
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
### PHI De-identification
|
|
171
|
+
|
|
172
|
+
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.
|
|
173
|
+
|
|
174
|
+
```python
|
|
175
|
+
result = client.anonymize(
|
|
176
|
+
"John Smith, DOB 01/15/1980, MRN 123456, has COPD"
|
|
177
|
+
)
|
|
178
|
+
|
|
179
|
+
print(result.anonymized_text)
|
|
180
|
+
# "[NAME], DOB [DATE], MRN [MRN], has COPD"
|
|
181
|
+
|
|
182
|
+
print(result.pii_count) # 3
|
|
183
|
+
print(result.pii_entities) # [PIIEntity(text="John Smith", label="NAME", ...), ...]
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
---
|
|
187
|
+
|
|
188
|
+
## Use Cases
|
|
189
|
+
|
|
190
|
+
- **EHR / EMR Integration** — Auto-code clinical notes as providers type, reducing manual coding burden
|
|
191
|
+
- **Medical Billing & RCM** — Accelerate claim submission with accurate ICD-10 codes
|
|
192
|
+
- **Clinical Decision Support** — Map patient conditions to standardized codes for analytics and alerts
|
|
193
|
+
- **Health-Tech SaaS** — Add ICD-10 coding to your platform without building ML infrastructure
|
|
194
|
+
- **Clinical Research** — Extract and standardize diagnoses from unstructured medical records
|
|
195
|
+
- **Insurance & Payer Systems** — Validate and suggest diagnosis codes during claims processing
|
|
196
|
+
- **Telehealth Platforms** — Generate diagnosis codes from visit notes and transcriptions
|
|
197
|
+
|
|
198
|
+
---
|
|
199
|
+
|
|
200
|
+
## Error Handling
|
|
201
|
+
|
|
202
|
+
```python
|
|
203
|
+
from autoicd import (
|
|
204
|
+
AutoICD,
|
|
205
|
+
AuthenticationError,
|
|
206
|
+
RateLimitError,
|
|
207
|
+
NotFoundError,
|
|
208
|
+
)
|
|
209
|
+
|
|
210
|
+
try:
|
|
211
|
+
result = client.code("...")
|
|
212
|
+
except AuthenticationError:
|
|
213
|
+
# Invalid or revoked API key (401)
|
|
214
|
+
...
|
|
215
|
+
except RateLimitError as e:
|
|
216
|
+
# Request limit exceeded (429)
|
|
217
|
+
print(e.rate_limit.remaining, e.rate_limit.reset_at)
|
|
218
|
+
except NotFoundError:
|
|
219
|
+
# ICD-10 code not found (404)
|
|
220
|
+
...
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
Rate limit info is available after every request:
|
|
224
|
+
|
|
225
|
+
```python
|
|
226
|
+
client.code("...")
|
|
227
|
+
print(client.last_rate_limit)
|
|
228
|
+
# RateLimit(limit=1000, remaining=987, reset_at=datetime(...))
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
---
|
|
232
|
+
|
|
233
|
+
## Configuration
|
|
234
|
+
|
|
235
|
+
```python
|
|
236
|
+
client = AutoICD(
|
|
237
|
+
api_key="sk_...", # Required — get yours at https://autoicdapi.com
|
|
238
|
+
base_url="https://...", # Default: https://autoicdapi.com
|
|
239
|
+
timeout=60.0, # Default: 30.0 seconds
|
|
240
|
+
http_client=httpx.Client(...), # Custom httpx client (for proxies, mTLS, etc.)
|
|
241
|
+
)
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
Use as a context manager for automatic cleanup:
|
|
245
|
+
|
|
246
|
+
```python
|
|
247
|
+
with AutoICD(api_key="sk_...") as client:
|
|
248
|
+
result = client.code("Patient has diabetes")
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
---
|
|
252
|
+
|
|
253
|
+
## API Reference
|
|
254
|
+
|
|
255
|
+
Full REST API documentation at [autoicdapi.com/docs](https://autoicdapi.com/docs).
|
|
256
|
+
|
|
257
|
+
| Method | Description |
|
|
258
|
+
|--------|-------------|
|
|
259
|
+
| `client.code(text, options?)` | Code clinical text to ICD-10-CM diagnoses |
|
|
260
|
+
| `client.anonymize(text)` | De-identify PHI/PII in clinical text |
|
|
261
|
+
| `client.codes.search(query, options?)` | Search ICD-10-CM codes by description |
|
|
262
|
+
| `client.codes.get(code)` | Get details for an ICD-10-CM code |
|
|
263
|
+
| `client.codes.terms(code)` | Get indexed terms/synonyms for a code |
|
|
264
|
+
|
|
265
|
+
---
|
|
266
|
+
|
|
267
|
+
## Types
|
|
268
|
+
|
|
269
|
+
All request and response types are exported:
|
|
270
|
+
|
|
271
|
+
```python
|
|
272
|
+
from autoicd import (
|
|
273
|
+
CodingResponse,
|
|
274
|
+
CodingEntity,
|
|
275
|
+
CodeMatch,
|
|
276
|
+
CodeOptions,
|
|
277
|
+
CodeDetail,
|
|
278
|
+
CodeSearchResponse,
|
|
279
|
+
CodeTermInfo,
|
|
280
|
+
AnonymizeResponse,
|
|
281
|
+
PIIEntity,
|
|
282
|
+
RateLimit,
|
|
283
|
+
SearchOptions,
|
|
284
|
+
)
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
---
|
|
288
|
+
|
|
289
|
+
## Requirements
|
|
290
|
+
|
|
291
|
+
- **Python 3.10+**
|
|
292
|
+
- An API key from [autoicdapi.com](https://autoicdapi.com)
|
|
293
|
+
|
|
294
|
+
---
|
|
295
|
+
|
|
296
|
+
## Links
|
|
297
|
+
|
|
298
|
+
- [AutoICD API](https://autoicdapi.com) — Homepage and API key management
|
|
299
|
+
- [API Documentation](https://autoicdapi.com/docs) — Full REST API reference
|
|
300
|
+
- [TypeScript SDK](https://www.npmjs.com/package/autoicd) — `npm install autoicd`
|
|
301
|
+
- [ICD-10-CM 2025 Code Set](https://www.cms.gov/medicare/coding-billing/icd-10-codes) — Official CMS reference
|
|
302
|
+
|
|
303
|
+
---
|
|
304
|
+
|
|
305
|
+
## License
|
|
306
|
+
|
|
307
|
+
MIT
|
autoicd-0.2.0/README.md
ADDED
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
# AutoICD API — Python SDK
|
|
2
|
+
|
|
3
|
+
[](https://pypi.org/project/autoicd/)
|
|
4
|
+
[](https://opensource.org/licenses/MIT)
|
|
5
|
+
[](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
|
+
strategy="merged", # "individual" or "merged" entity strategy
|
|
99
|
+
include_negated=False, # Exclude negated conditions from results
|
|
100
|
+
),
|
|
101
|
+
)
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### ICD-10 Code Search
|
|
105
|
+
|
|
106
|
+
Search the full ICD-10-CM 2025 code set by description. Perfect for building code lookup UIs, autocomplete fields, and validation workflows.
|
|
107
|
+
|
|
108
|
+
```python
|
|
109
|
+
results = client.codes.search("diabetes mellitus")
|
|
110
|
+
# results.codes → [CodeDetail(code="E11.9", short_description="...", ...), ...]
|
|
111
|
+
|
|
112
|
+
from autoicd import SearchOptions
|
|
113
|
+
results = client.codes.search("heart failure", options=SearchOptions(limit=5))
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### ICD-10 Code Details
|
|
117
|
+
|
|
118
|
+
Get full details for any ICD-10-CM code — descriptions, billable status, and indexed terms.
|
|
119
|
+
|
|
120
|
+
```python
|
|
121
|
+
detail = client.codes.get("E11.9")
|
|
122
|
+
print(detail.code) # "E11.9"
|
|
123
|
+
print(detail.long_description) # "Type 2 diabetes mellitus without complications"
|
|
124
|
+
print(detail.is_billable) # True
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
### ICD-10 Code Terms & Synonyms
|
|
128
|
+
|
|
129
|
+
Retrieve all indexed terms and synonyms for a code — includes SNOMED CT mappings and clinical variants.
|
|
130
|
+
|
|
131
|
+
```python
|
|
132
|
+
terms = client.codes.terms("E11.9")
|
|
133
|
+
for t in terms:
|
|
134
|
+
print(t.term, f"({t.term_type})")
|
|
135
|
+
# "Type 2 diabetes mellitus without complications" (long_desc)
|
|
136
|
+
# "adult onset diabetes" (synonym)
|
|
137
|
+
# ...
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### PHI De-identification
|
|
141
|
+
|
|
142
|
+
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.
|
|
143
|
+
|
|
144
|
+
```python
|
|
145
|
+
result = client.anonymize(
|
|
146
|
+
"John Smith, DOB 01/15/1980, MRN 123456, has COPD"
|
|
147
|
+
)
|
|
148
|
+
|
|
149
|
+
print(result.anonymized_text)
|
|
150
|
+
# "[NAME], DOB [DATE], MRN [MRN], has COPD"
|
|
151
|
+
|
|
152
|
+
print(result.pii_count) # 3
|
|
153
|
+
print(result.pii_entities) # [PIIEntity(text="John Smith", label="NAME", ...), ...]
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
---
|
|
157
|
+
|
|
158
|
+
## Use Cases
|
|
159
|
+
|
|
160
|
+
- **EHR / EMR Integration** — Auto-code clinical notes as providers type, reducing manual coding burden
|
|
161
|
+
- **Medical Billing & RCM** — Accelerate claim submission with accurate ICD-10 codes
|
|
162
|
+
- **Clinical Decision Support** — Map patient conditions to standardized codes for analytics and alerts
|
|
163
|
+
- **Health-Tech SaaS** — Add ICD-10 coding to your platform without building ML infrastructure
|
|
164
|
+
- **Clinical Research** — Extract and standardize diagnoses from unstructured medical records
|
|
165
|
+
- **Insurance & Payer Systems** — Validate and suggest diagnosis codes during claims processing
|
|
166
|
+
- **Telehealth Platforms** — Generate diagnosis codes from visit notes and transcriptions
|
|
167
|
+
|
|
168
|
+
---
|
|
169
|
+
|
|
170
|
+
## Error Handling
|
|
171
|
+
|
|
172
|
+
```python
|
|
173
|
+
from autoicd import (
|
|
174
|
+
AutoICD,
|
|
175
|
+
AuthenticationError,
|
|
176
|
+
RateLimitError,
|
|
177
|
+
NotFoundError,
|
|
178
|
+
)
|
|
179
|
+
|
|
180
|
+
try:
|
|
181
|
+
result = client.code("...")
|
|
182
|
+
except AuthenticationError:
|
|
183
|
+
# Invalid or revoked API key (401)
|
|
184
|
+
...
|
|
185
|
+
except RateLimitError as e:
|
|
186
|
+
# Request limit exceeded (429)
|
|
187
|
+
print(e.rate_limit.remaining, e.rate_limit.reset_at)
|
|
188
|
+
except NotFoundError:
|
|
189
|
+
# ICD-10 code not found (404)
|
|
190
|
+
...
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
Rate limit info is available after every request:
|
|
194
|
+
|
|
195
|
+
```python
|
|
196
|
+
client.code("...")
|
|
197
|
+
print(client.last_rate_limit)
|
|
198
|
+
# RateLimit(limit=1000, remaining=987, reset_at=datetime(...))
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
---
|
|
202
|
+
|
|
203
|
+
## Configuration
|
|
204
|
+
|
|
205
|
+
```python
|
|
206
|
+
client = AutoICD(
|
|
207
|
+
api_key="sk_...", # Required — get yours at https://autoicdapi.com
|
|
208
|
+
base_url="https://...", # Default: https://autoicdapi.com
|
|
209
|
+
timeout=60.0, # Default: 30.0 seconds
|
|
210
|
+
http_client=httpx.Client(...), # Custom httpx client (for proxies, mTLS, etc.)
|
|
211
|
+
)
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
Use as a context manager for automatic cleanup:
|
|
215
|
+
|
|
216
|
+
```python
|
|
217
|
+
with AutoICD(api_key="sk_...") as client:
|
|
218
|
+
result = client.code("Patient has diabetes")
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
---
|
|
222
|
+
|
|
223
|
+
## API Reference
|
|
224
|
+
|
|
225
|
+
Full REST API documentation at [autoicdapi.com/docs](https://autoicdapi.com/docs).
|
|
226
|
+
|
|
227
|
+
| Method | Description |
|
|
228
|
+
|--------|-------------|
|
|
229
|
+
| `client.code(text, options?)` | Code clinical text to ICD-10-CM diagnoses |
|
|
230
|
+
| `client.anonymize(text)` | De-identify PHI/PII in clinical text |
|
|
231
|
+
| `client.codes.search(query, options?)` | Search ICD-10-CM codes by description |
|
|
232
|
+
| `client.codes.get(code)` | Get details for an ICD-10-CM code |
|
|
233
|
+
| `client.codes.terms(code)` | Get indexed terms/synonyms for a code |
|
|
234
|
+
|
|
235
|
+
---
|
|
236
|
+
|
|
237
|
+
## Types
|
|
238
|
+
|
|
239
|
+
All request and response types are exported:
|
|
240
|
+
|
|
241
|
+
```python
|
|
242
|
+
from autoicd import (
|
|
243
|
+
CodingResponse,
|
|
244
|
+
CodingEntity,
|
|
245
|
+
CodeMatch,
|
|
246
|
+
CodeOptions,
|
|
247
|
+
CodeDetail,
|
|
248
|
+
CodeSearchResponse,
|
|
249
|
+
CodeTermInfo,
|
|
250
|
+
AnonymizeResponse,
|
|
251
|
+
PIIEntity,
|
|
252
|
+
RateLimit,
|
|
253
|
+
SearchOptions,
|
|
254
|
+
)
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
---
|
|
258
|
+
|
|
259
|
+
## Requirements
|
|
260
|
+
|
|
261
|
+
- **Python 3.10+**
|
|
262
|
+
- An API key from [autoicdapi.com](https://autoicdapi.com)
|
|
263
|
+
|
|
264
|
+
---
|
|
265
|
+
|
|
266
|
+
## Links
|
|
267
|
+
|
|
268
|
+
- [AutoICD API](https://autoicdapi.com) — Homepage and API key management
|
|
269
|
+
- [API Documentation](https://autoicdapi.com/docs) — Full REST API reference
|
|
270
|
+
- [TypeScript SDK](https://www.npmjs.com/package/autoicd) — `npm install autoicd`
|
|
271
|
+
- [ICD-10-CM 2025 Code Set](https://www.cms.gov/medicare/coding-billing/icd-10-codes) — Official CMS reference
|
|
272
|
+
|
|
273
|
+
---
|
|
274
|
+
|
|
275
|
+
## License
|
|
276
|
+
|
|
277
|
+
MIT
|