autoicd-js 0.10.0 → 0.11.0
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.
- package/README.md +93 -6
- package/dist/index.d.mts +107 -3
- package/dist/index.d.ts +107 -3
- package/dist/index.js +26 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +26 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +11 -3
package/README.md
CHANGED
|
@@ -12,6 +12,14 @@ Zero dependencies. Works in **Node.js 18+**, **Deno**, **Bun**, and **edge runti
|
|
|
12
12
|
|
|
13
13
|
---
|
|
14
14
|
|
|
15
|
+
## What's new — 2026-05-05
|
|
16
|
+
|
|
17
|
+
- **Phase 3 unified reference lookup.** A single `client.reference.lookup(system, code)` covers ICD-10-CM, ICD-11, ICF, LOINC, SNOMED CT, UMLS, and RxNorm. The legacy per-system getters (`icd10.get`, `icd11.get`, `icf.lookup`, `loinc.lookup`) keep working but the underlying routes now emit `Deprecation` and `Sunset` headers.
|
|
18
|
+
- **Phase 4 SNOMED CT, UMLS, and RxNorm coverage.** Lookup canonical concept records (preferred terms, synonyms, semantic types) and search those vocabularies via `client.reference.search(system, query)`.
|
|
19
|
+
- **Cross-references everywhere.** ICD-10, ICD-11, LOINC, SNOMED, UMLS, and RxNorm records all carry `cross_references` keyed by target system, so you can pivot between vocabularies without extra calls.
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
15
23
|
## Why AutoICD API
|
|
16
24
|
|
|
17
25
|
| | |
|
|
@@ -117,6 +125,52 @@ Default behavior runs all five capabilities. Pass `capabilities: ["hcc"]` to run
|
|
|
117
125
|
|
|
118
126
|
Read more about the Audit endpoint at [autoicdapi.com/audit](https://autoicdapi.com/audit).
|
|
119
127
|
|
|
128
|
+
### Unified Reference Lookup (ICD-10, ICD-11, ICF, LOINC, SNOMED, UMLS, RxNorm)
|
|
129
|
+
|
|
130
|
+
One call to fetch canonical record data for any code in any supported system. The response is a discriminated union — narrow on `result.system` to access the system-specific shape.
|
|
131
|
+
|
|
132
|
+
```ts
|
|
133
|
+
const icd10 = await autoicd.reference.lookup("icd-10-cm", "E11.9");
|
|
134
|
+
if (icd10.system === "icd-10-cm") {
|
|
135
|
+
console.log(icd10.record.long_description);
|
|
136
|
+
console.log(icd10.record.cross_references); // { snomed: [...], umls: [...], rxnorm: [...] }
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
const concept = await autoicd.reference.lookup("snomed-ct", "44054006");
|
|
140
|
+
if (concept.system === "snomed-ct") {
|
|
141
|
+
console.log(concept.record.preferred_term); // "Diabetes mellitus type 2"
|
|
142
|
+
console.log(concept.record.semantic_tag); // "disorder"
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
const cui = await autoicd.reference.lookup("umls", "C0011860");
|
|
146
|
+
if (cui.system === "umls") {
|
|
147
|
+
console.log(cui.record.preferred_name);
|
|
148
|
+
console.log(cui.record.cross_references.snomed);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
const drug = await autoicd.reference.lookup("rxnorm", "860975"); // metformin 500 MG
|
|
152
|
+
if (drug.system === "rxnorm") {
|
|
153
|
+
console.log(drug.record.name, drug.record.tty);
|
|
154
|
+
}
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
Supported `system` values: `"icd-10-cm"`, `"icd-11"`, `"icf"`, `"loinc"`, `"snomed-ct"`, `"umls"`, `"rxnorm"`.
|
|
158
|
+
|
|
159
|
+
### Reference Search (SNOMED CT, UMLS, RxNorm)
|
|
160
|
+
|
|
161
|
+
Free-text search the Neon-backed reference vocabularies. ICD-10, ICD-11, ICF, and LOINC keep their per-system search endpoints.
|
|
162
|
+
|
|
163
|
+
```ts
|
|
164
|
+
const hits = await autoicd.reference.search("snomed-ct", "type 2 diabetes", { limit: 5 });
|
|
165
|
+
for (const hit of hits.results) {
|
|
166
|
+
console.log(hit.code, hit.label, hit.meta);
|
|
167
|
+
// 44054006 "Diabetes mellitus type 2 (disorder)" "disorder"
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
const cuis = await autoicd.reference.search("umls", "metformin");
|
|
171
|
+
const drugs = await autoicd.reference.search("rxnorm", "lisinopril 10 mg", { limit: 10 });
|
|
172
|
+
```
|
|
173
|
+
|
|
120
174
|
### Cross-Standard Code Translation
|
|
121
175
|
|
|
122
176
|
Translate a code between healthcare coding systems in one call. Forward from ICD-10 to ICD-11, SNOMED CT, UMLS, and ICF, plus reverse ICD-11 → ICD-10 and ICF → ICD-10. Built on CMS-published crosswalks, code-level SNOMED / UMLS concept IDs, and WHO ICF Core Sets.
|
|
@@ -389,14 +443,21 @@ Full REST API documentation at [autoicdapi.com/docs](https://autoicdapi.com/docs
|
|
|
389
443
|
| Method | Description |
|
|
390
444
|
|--------|-------------|
|
|
391
445
|
| `autoicd.code(text, options?)` | Code clinical text to ICD-10-CM diagnoses |
|
|
446
|
+
| `autoicd.audit(request)` | Chart audit (HCC gap capture, RADV, specificity, denial, problem list) |
|
|
447
|
+
| `autoicd.translate(request)` | Cross-standard code translation across ICD-10, ICD-11, SNOMED, UMLS, ICF |
|
|
392
448
|
| `autoicd.anonymize(text)` | De-identify PHI/PII in clinical text |
|
|
449
|
+
| `autoicd.reference.lookup(system, code)` | Unified lookup across ICD-10-CM, ICD-11, ICF, LOINC, SNOMED CT, UMLS, RxNorm |
|
|
450
|
+
| `autoicd.reference.search(system, query, options?)` | Free-text search of SNOMED CT, UMLS, or RxNorm |
|
|
393
451
|
| `autoicd.icd10.search(query, options?)` | Search ICD-10-CM codes by description |
|
|
394
|
-
| `autoicd.icd10.get(code)` | Get details for an ICD-10-CM code (
|
|
452
|
+
| `autoicd.icd10.get(code)` | Get details for an ICD-10-CM code (deprecated — use `reference.lookup`) |
|
|
395
453
|
| `autoicd.icd11.search(query, options?)` | Search ICD-11 codes by description |
|
|
396
|
-
| `autoicd.icd11.get(code)` | Get details for an ICD-11 code (
|
|
397
|
-
| `autoicd.icf.lookup(code)` | Get details for an ICF code |
|
|
454
|
+
| `autoicd.icd11.get(code)` | Get details for an ICD-11 code (deprecated — use `reference.lookup`) |
|
|
455
|
+
| `autoicd.icf.lookup(code)` | Get details for an ICF code (deprecated — use `reference.lookup`) |
|
|
398
456
|
| `autoicd.icf.search(query, options?)` | Search ICF codes by keyword |
|
|
399
457
|
| `autoicd.icf.coreSet(icd10Code)` | Get ICF Core Set for an ICD-10 diagnosis |
|
|
458
|
+
| `autoicd.loinc.code(text, options?)` | Code clinical text to LOINC lab/observation codes |
|
|
459
|
+
| `autoicd.loinc.lookup(code)` | Get details for a LOINC code (deprecated — use `reference.lookup`) |
|
|
460
|
+
| `autoicd.loinc.search(query, options?)` | Search LOINC codes by description |
|
|
400
461
|
|
|
401
462
|
---
|
|
402
463
|
|
|
@@ -411,6 +472,7 @@ import type {
|
|
|
411
472
|
CodeMatch,
|
|
412
473
|
CodeOptions,
|
|
413
474
|
CodeDetail,
|
|
475
|
+
CodeDetailFull,
|
|
414
476
|
CodeSearchResponse,
|
|
415
477
|
AnonymizeResponse,
|
|
416
478
|
PIIEntity,
|
|
@@ -420,8 +482,32 @@ import type {
|
|
|
420
482
|
ICD11CodeSearchResponse,
|
|
421
483
|
CrosswalkMapping,
|
|
422
484
|
ICFCodeDetail,
|
|
423
|
-
|
|
424
|
-
|
|
485
|
+
ICFSearchResponse,
|
|
486
|
+
ICFCoreSetResult,
|
|
487
|
+
LOINCCodeDetail,
|
|
488
|
+
LOINCSearchResponse,
|
|
489
|
+
LOINCCodingResponse,
|
|
490
|
+
// Audit
|
|
491
|
+
AuditRequest,
|
|
492
|
+
AuditResponse,
|
|
493
|
+
AuditCapability,
|
|
494
|
+
MissedCode,
|
|
495
|
+
UnsupportedCode,
|
|
496
|
+
SpecificityUpgrade,
|
|
497
|
+
DenialRisk,
|
|
498
|
+
ProblemListEntry,
|
|
499
|
+
// Translate
|
|
500
|
+
TranslateRequest,
|
|
501
|
+
TranslateResponse,
|
|
502
|
+
InteropSystem,
|
|
503
|
+
// Unified reference lookup (Phase 3 + Phase 4)
|
|
504
|
+
ReferenceSystem,
|
|
505
|
+
ReferenceCodeRecord,
|
|
506
|
+
SearchableReferenceSystem,
|
|
507
|
+
ReferenceSearchResponse,
|
|
508
|
+
SnomedCodeDetail,
|
|
509
|
+
UmlsCodeDetail,
|
|
510
|
+
RxnormCodeDetail,
|
|
425
511
|
} from "autoicd";
|
|
426
512
|
```
|
|
427
513
|
|
|
@@ -443,7 +529,8 @@ import type {
|
|
|
443
529
|
- [ICD-10 ↔ ICD-11 Crosswalk](https://autoicdapi.com/icd10-to-icd11) — Map codes between revisions
|
|
444
530
|
- [ICD-10 Codes by Condition](https://autoicdapi.com/reference/icd-10/condition) — Find codes for common conditions
|
|
445
531
|
- [Python SDK](https://pypi.org/project/autoicd/) — `pip install autoicd`
|
|
446
|
-
- [MCP Server](https://www.npmjs.com/package/autoicd-mcp) — For Claude Desktop, Cursor, VS Code
|
|
532
|
+
- [AutoICD MCP Server](https://www.npmjs.com/package/autoicd-mcp) — For Claude Desktop, Cursor, VS Code, Windsurf, and the remote endpoint at `autoicdapi.com/api/mcp`
|
|
533
|
+
- [Postman Collection](https://autoicdapi.com/docs) — Importable collection for the full REST surface
|
|
447
534
|
- [SNOMED CT & UMLS Cross-References](https://autoicdapi.com/snomed-ct-umls) — Terminology mappings
|
|
448
535
|
- [ICD-10-CM 2025 Code Set](https://www.cms.gov/medicare/coding-billing/icd-10-codes) — Official CMS reference
|
|
449
536
|
|
package/dist/index.d.mts
CHANGED
|
@@ -592,8 +592,60 @@ interface TranslateResponse {
|
|
|
592
592
|
unsupported_targets: InteropSystem[];
|
|
593
593
|
provider: string;
|
|
594
594
|
}
|
|
595
|
-
/**
|
|
596
|
-
|
|
595
|
+
/** Canonical SNOMED CT concept record. */
|
|
596
|
+
interface SnomedCodeDetail {
|
|
597
|
+
/** SNOMED CT concept ID (SCTID). */
|
|
598
|
+
concept_id: string;
|
|
599
|
+
/** Fully Specified Name. */
|
|
600
|
+
fsn: string;
|
|
601
|
+
/** Preferred Term. */
|
|
602
|
+
preferred_term: string;
|
|
603
|
+
/** Semantic tag from the FSN (e.g. `"disorder"`, `"finding"`). */
|
|
604
|
+
semantic_tag: string;
|
|
605
|
+
/** Whether the concept is active in the latest release. */
|
|
606
|
+
active: boolean;
|
|
607
|
+
/** Synonym terms. */
|
|
608
|
+
synonyms: string[];
|
|
609
|
+
/** Cross-reference IDs grouped by system: `"icd10"`, `"icd11"`, `"loinc"`, `"umls"`, `"rxnorm"`. */
|
|
610
|
+
cross_references: Record<string, string[]>;
|
|
611
|
+
}
|
|
612
|
+
/** Single source-vocabulary atom underlying a UMLS concept. */
|
|
613
|
+
interface UmlsAtomDetail {
|
|
614
|
+
source_vocabulary: string;
|
|
615
|
+
source_code: string;
|
|
616
|
+
term_type: string;
|
|
617
|
+
description: string;
|
|
618
|
+
}
|
|
619
|
+
/** Canonical UMLS Metathesaurus concept record. */
|
|
620
|
+
interface UmlsCodeDetail {
|
|
621
|
+
/** UMLS Concept Unique Identifier. */
|
|
622
|
+
cui: string;
|
|
623
|
+
/** Preferred concept name. */
|
|
624
|
+
preferred_name: string;
|
|
625
|
+
/** Semantic types (TUIs / labels). */
|
|
626
|
+
semantic_types: string[];
|
|
627
|
+
/** Source-vocabulary atoms behind the concept. */
|
|
628
|
+
atoms: UmlsAtomDetail[];
|
|
629
|
+
/** Cross-reference IDs grouped by system: `"icd10"`, `"snomed"`, `"loinc"`, `"rxnorm"`. */
|
|
630
|
+
cross_references: Record<string, string[]>;
|
|
631
|
+
}
|
|
632
|
+
/** Canonical RxNorm concept record. */
|
|
633
|
+
interface RxnormCodeDetail {
|
|
634
|
+
/** RxNorm concept identifier. */
|
|
635
|
+
rxcui: string;
|
|
636
|
+
/** Concept name. */
|
|
637
|
+
name: string;
|
|
638
|
+
/** Term type (e.g. `"IN"`, `"BN"`, `"SCD"`). */
|
|
639
|
+
tty: string;
|
|
640
|
+
/** Language code. */
|
|
641
|
+
language: string;
|
|
642
|
+
/** Synonym terms. */
|
|
643
|
+
synonyms: string[];
|
|
644
|
+
/** Cross-reference IDs grouped by system: `"umls"`, `"snomed"`, `"icd10"`, `"loinc"`. */
|
|
645
|
+
cross_references: Record<string, string[]>;
|
|
646
|
+
}
|
|
647
|
+
/** Coding system slugs accepted by `client.reference.lookup` and `client.reference.search`. */
|
|
648
|
+
type ReferenceSystem = "icd-10-cm" | "icd-11" | "icf" | "loinc" | "snomed-ct" | "umls" | "rxnorm";
|
|
597
649
|
/**
|
|
598
650
|
* Discriminated record returned by `GET /v1/reference/{system}/{code}`.
|
|
599
651
|
* `system` tags the variant; `record` carries the system-specific shape.
|
|
@@ -614,7 +666,37 @@ type ReferenceCodeRecord = {
|
|
|
614
666
|
system: "loinc";
|
|
615
667
|
code: string;
|
|
616
668
|
record: LOINCCodeDetail;
|
|
669
|
+
} | {
|
|
670
|
+
system: "snomed-ct";
|
|
671
|
+
code: string;
|
|
672
|
+
record: SnomedCodeDetail;
|
|
673
|
+
} | {
|
|
674
|
+
system: "umls";
|
|
675
|
+
code: string;
|
|
676
|
+
record: UmlsCodeDetail;
|
|
677
|
+
} | {
|
|
678
|
+
system: "rxnorm";
|
|
679
|
+
code: string;
|
|
680
|
+
record: RxnormCodeDetail;
|
|
617
681
|
};
|
|
682
|
+
/** Coding system slugs accepted by `client.reference.search`. */
|
|
683
|
+
type SearchableReferenceSystem = "snomed-ct" | "umls" | "rxnorm";
|
|
684
|
+
/** A single search hit returned by `GET /v1/reference/{system}/search`. */
|
|
685
|
+
interface ReferenceSearchHit {
|
|
686
|
+
/** Code in the searched system. */
|
|
687
|
+
code: string;
|
|
688
|
+
/** Display label (preferred term, name, etc.). */
|
|
689
|
+
label: string;
|
|
690
|
+
/** Optional system-specific metadata (semantic tag, term type). */
|
|
691
|
+
meta?: string;
|
|
692
|
+
}
|
|
693
|
+
/** Response shape for `GET /v1/reference/{system}/search`. */
|
|
694
|
+
interface ReferenceSearchResponse {
|
|
695
|
+
query: string;
|
|
696
|
+
system: SearchableReferenceSystem;
|
|
697
|
+
count: number;
|
|
698
|
+
results: ReferenceSearchHit[];
|
|
699
|
+
}
|
|
618
700
|
|
|
619
701
|
declare class AutoICD {
|
|
620
702
|
private readonly apiKey;
|
|
@@ -835,6 +917,7 @@ declare class ReferenceCodes {
|
|
|
835
917
|
constructor(client: AutoICD);
|
|
836
918
|
/**
|
|
837
919
|
* Look up canonical reference data for a code in any supported coding system.
|
|
920
|
+
* Supports ICD-10-CM, ICD-11, ICF, LOINC, SNOMED CT, UMLS, and RxNorm.
|
|
838
921
|
*
|
|
839
922
|
* Supersedes the per-system getters (`icd10.get`, `icd11.get`, `icf.lookup`,
|
|
840
923
|
* `loinc.lookup`), which remain available but emit `Deprecation` and `Sunset`
|
|
@@ -846,9 +929,30 @@ declare class ReferenceCodes {
|
|
|
846
929
|
* if (result.system === "icd-10-cm") {
|
|
847
930
|
* console.log(result.record.long_description);
|
|
848
931
|
* }
|
|
932
|
+
*
|
|
933
|
+
* const concept = await autoicd.reference.lookup("snomed-ct", "44054006");
|
|
934
|
+
* if (concept.system === "snomed-ct") {
|
|
935
|
+
* console.log(concept.record.preferred_term);
|
|
936
|
+
* }
|
|
849
937
|
* ```
|
|
850
938
|
*/
|
|
851
939
|
lookup(system: ReferenceSystem, code: string): Promise<ReferenceCodeRecord>;
|
|
940
|
+
/**
|
|
941
|
+
* Search SNOMED CT, UMLS, or RxNorm by free-text query. JSON-backed systems
|
|
942
|
+
* (ICD-10-CM, ICD-11, ICF, LOINC) keep their per-system search endpoints
|
|
943
|
+
* (`autoicd.icd10.search`, `autoicd.icd11.search`, ...).
|
|
944
|
+
*
|
|
945
|
+
* @example
|
|
946
|
+
* ```ts
|
|
947
|
+
* const hits = await autoicd.reference.search("snomed-ct", "type 2 diabetes", { limit: 5 });
|
|
948
|
+
* for (const hit of hits.results) {
|
|
949
|
+
* console.log(hit.code, hit.label, hit.meta);
|
|
950
|
+
* }
|
|
951
|
+
* ```
|
|
952
|
+
*/
|
|
953
|
+
search(system: SearchableReferenceSystem, query: string, options?: {
|
|
954
|
+
limit?: number;
|
|
955
|
+
}): Promise<ReferenceSearchResponse>;
|
|
852
956
|
}
|
|
853
957
|
|
|
854
958
|
declare class AutoICDError extends Error {
|
|
@@ -866,4 +970,4 @@ declare class NotFoundError extends AutoICDError {
|
|
|
866
970
|
constructor(message?: string);
|
|
867
971
|
}
|
|
868
972
|
|
|
869
|
-
export { type AnonymizeResponse, type AuditCapability, type AuditCode, type AuditContext, type AuditDocument, type AuditRequest, type AuditResponse, type AuditTotals, AuthenticationError, AutoICD, AutoICDError, type AutoICDOptions, type ChapterInfo, type CodeDetail, type CodeDetailFull, type CodeMatch, type CodeOptions, type CodeSearchResponse, type CodingEntity, type CodingResponse, type ConfirmedCode, type CrosswalkMapping, type DenialRisk, type EvidenceSpan, type ICD11ChapterInfo, type ICD11CodeDetail, type ICD11CodeDetailFull, type ICD11CodeSearchResponse, type ICD11CodeSearchResult, type ICFCodeDetail, type ICFCodeResult, type ICFCodeSummary, type ICFCodingEntity, type ICFComponent, type ICFCoreSetResult, type ICFCrossReference, type ICFSearchResponse, type InteropSystem, type LOINCCodeDetail, type LOINCCodeResult, type LOINCCodeSummary, type LOINCCodingEntity, type LOINCCodingResponse, type LOINCSearchResponse, type MissedCode, NotFoundError, type PIIEntity, type ProblemListEntry, type RateLimit, RateLimitError, type RatesUsed, type ReferenceCodeRecord, type ReferenceSystem, type SearchOptions, type SpecificityUpgrade, type TranslateMapping, type TranslateRequest, type TranslateResponse, type TranslateSource, type UnsupportedCode, type UpgradeHint };
|
|
973
|
+
export { type AnonymizeResponse, type AuditCapability, type AuditCode, type AuditContext, type AuditDocument, type AuditRequest, type AuditResponse, type AuditTotals, AuthenticationError, AutoICD, AutoICDError, type AutoICDOptions, type ChapterInfo, type CodeDetail, type CodeDetailFull, type CodeMatch, type CodeOptions, type CodeSearchResponse, type CodingEntity, type CodingResponse, type ConfirmedCode, type CrosswalkMapping, type DenialRisk, type EvidenceSpan, type ICD11ChapterInfo, type ICD11CodeDetail, type ICD11CodeDetailFull, type ICD11CodeSearchResponse, type ICD11CodeSearchResult, type ICFCodeDetail, type ICFCodeResult, type ICFCodeSummary, type ICFCodingEntity, type ICFComponent, type ICFCoreSetResult, type ICFCrossReference, type ICFSearchResponse, type InteropSystem, type LOINCCodeDetail, type LOINCCodeResult, type LOINCCodeSummary, type LOINCCodingEntity, type LOINCCodingResponse, type LOINCSearchResponse, type MissedCode, NotFoundError, type PIIEntity, type ProblemListEntry, type RateLimit, RateLimitError, type RatesUsed, type ReferenceCodeRecord, type ReferenceSearchHit, type ReferenceSearchResponse, type ReferenceSystem, type RxnormCodeDetail, type SearchOptions, type SearchableReferenceSystem, type SnomedCodeDetail, type SpecificityUpgrade, type TranslateMapping, type TranslateRequest, type TranslateResponse, type TranslateSource, type UmlsAtomDetail, type UmlsCodeDetail, type UnsupportedCode, type UpgradeHint };
|
package/dist/index.d.ts
CHANGED
|
@@ -592,8 +592,60 @@ interface TranslateResponse {
|
|
|
592
592
|
unsupported_targets: InteropSystem[];
|
|
593
593
|
provider: string;
|
|
594
594
|
}
|
|
595
|
-
/**
|
|
596
|
-
|
|
595
|
+
/** Canonical SNOMED CT concept record. */
|
|
596
|
+
interface SnomedCodeDetail {
|
|
597
|
+
/** SNOMED CT concept ID (SCTID). */
|
|
598
|
+
concept_id: string;
|
|
599
|
+
/** Fully Specified Name. */
|
|
600
|
+
fsn: string;
|
|
601
|
+
/** Preferred Term. */
|
|
602
|
+
preferred_term: string;
|
|
603
|
+
/** Semantic tag from the FSN (e.g. `"disorder"`, `"finding"`). */
|
|
604
|
+
semantic_tag: string;
|
|
605
|
+
/** Whether the concept is active in the latest release. */
|
|
606
|
+
active: boolean;
|
|
607
|
+
/** Synonym terms. */
|
|
608
|
+
synonyms: string[];
|
|
609
|
+
/** Cross-reference IDs grouped by system: `"icd10"`, `"icd11"`, `"loinc"`, `"umls"`, `"rxnorm"`. */
|
|
610
|
+
cross_references: Record<string, string[]>;
|
|
611
|
+
}
|
|
612
|
+
/** Single source-vocabulary atom underlying a UMLS concept. */
|
|
613
|
+
interface UmlsAtomDetail {
|
|
614
|
+
source_vocabulary: string;
|
|
615
|
+
source_code: string;
|
|
616
|
+
term_type: string;
|
|
617
|
+
description: string;
|
|
618
|
+
}
|
|
619
|
+
/** Canonical UMLS Metathesaurus concept record. */
|
|
620
|
+
interface UmlsCodeDetail {
|
|
621
|
+
/** UMLS Concept Unique Identifier. */
|
|
622
|
+
cui: string;
|
|
623
|
+
/** Preferred concept name. */
|
|
624
|
+
preferred_name: string;
|
|
625
|
+
/** Semantic types (TUIs / labels). */
|
|
626
|
+
semantic_types: string[];
|
|
627
|
+
/** Source-vocabulary atoms behind the concept. */
|
|
628
|
+
atoms: UmlsAtomDetail[];
|
|
629
|
+
/** Cross-reference IDs grouped by system: `"icd10"`, `"snomed"`, `"loinc"`, `"rxnorm"`. */
|
|
630
|
+
cross_references: Record<string, string[]>;
|
|
631
|
+
}
|
|
632
|
+
/** Canonical RxNorm concept record. */
|
|
633
|
+
interface RxnormCodeDetail {
|
|
634
|
+
/** RxNorm concept identifier. */
|
|
635
|
+
rxcui: string;
|
|
636
|
+
/** Concept name. */
|
|
637
|
+
name: string;
|
|
638
|
+
/** Term type (e.g. `"IN"`, `"BN"`, `"SCD"`). */
|
|
639
|
+
tty: string;
|
|
640
|
+
/** Language code. */
|
|
641
|
+
language: string;
|
|
642
|
+
/** Synonym terms. */
|
|
643
|
+
synonyms: string[];
|
|
644
|
+
/** Cross-reference IDs grouped by system: `"umls"`, `"snomed"`, `"icd10"`, `"loinc"`. */
|
|
645
|
+
cross_references: Record<string, string[]>;
|
|
646
|
+
}
|
|
647
|
+
/** Coding system slugs accepted by `client.reference.lookup` and `client.reference.search`. */
|
|
648
|
+
type ReferenceSystem = "icd-10-cm" | "icd-11" | "icf" | "loinc" | "snomed-ct" | "umls" | "rxnorm";
|
|
597
649
|
/**
|
|
598
650
|
* Discriminated record returned by `GET /v1/reference/{system}/{code}`.
|
|
599
651
|
* `system` tags the variant; `record` carries the system-specific shape.
|
|
@@ -614,7 +666,37 @@ type ReferenceCodeRecord = {
|
|
|
614
666
|
system: "loinc";
|
|
615
667
|
code: string;
|
|
616
668
|
record: LOINCCodeDetail;
|
|
669
|
+
} | {
|
|
670
|
+
system: "snomed-ct";
|
|
671
|
+
code: string;
|
|
672
|
+
record: SnomedCodeDetail;
|
|
673
|
+
} | {
|
|
674
|
+
system: "umls";
|
|
675
|
+
code: string;
|
|
676
|
+
record: UmlsCodeDetail;
|
|
677
|
+
} | {
|
|
678
|
+
system: "rxnorm";
|
|
679
|
+
code: string;
|
|
680
|
+
record: RxnormCodeDetail;
|
|
617
681
|
};
|
|
682
|
+
/** Coding system slugs accepted by `client.reference.search`. */
|
|
683
|
+
type SearchableReferenceSystem = "snomed-ct" | "umls" | "rxnorm";
|
|
684
|
+
/** A single search hit returned by `GET /v1/reference/{system}/search`. */
|
|
685
|
+
interface ReferenceSearchHit {
|
|
686
|
+
/** Code in the searched system. */
|
|
687
|
+
code: string;
|
|
688
|
+
/** Display label (preferred term, name, etc.). */
|
|
689
|
+
label: string;
|
|
690
|
+
/** Optional system-specific metadata (semantic tag, term type). */
|
|
691
|
+
meta?: string;
|
|
692
|
+
}
|
|
693
|
+
/** Response shape for `GET /v1/reference/{system}/search`. */
|
|
694
|
+
interface ReferenceSearchResponse {
|
|
695
|
+
query: string;
|
|
696
|
+
system: SearchableReferenceSystem;
|
|
697
|
+
count: number;
|
|
698
|
+
results: ReferenceSearchHit[];
|
|
699
|
+
}
|
|
618
700
|
|
|
619
701
|
declare class AutoICD {
|
|
620
702
|
private readonly apiKey;
|
|
@@ -835,6 +917,7 @@ declare class ReferenceCodes {
|
|
|
835
917
|
constructor(client: AutoICD);
|
|
836
918
|
/**
|
|
837
919
|
* Look up canonical reference data for a code in any supported coding system.
|
|
920
|
+
* Supports ICD-10-CM, ICD-11, ICF, LOINC, SNOMED CT, UMLS, and RxNorm.
|
|
838
921
|
*
|
|
839
922
|
* Supersedes the per-system getters (`icd10.get`, `icd11.get`, `icf.lookup`,
|
|
840
923
|
* `loinc.lookup`), which remain available but emit `Deprecation` and `Sunset`
|
|
@@ -846,9 +929,30 @@ declare class ReferenceCodes {
|
|
|
846
929
|
* if (result.system === "icd-10-cm") {
|
|
847
930
|
* console.log(result.record.long_description);
|
|
848
931
|
* }
|
|
932
|
+
*
|
|
933
|
+
* const concept = await autoicd.reference.lookup("snomed-ct", "44054006");
|
|
934
|
+
* if (concept.system === "snomed-ct") {
|
|
935
|
+
* console.log(concept.record.preferred_term);
|
|
936
|
+
* }
|
|
849
937
|
* ```
|
|
850
938
|
*/
|
|
851
939
|
lookup(system: ReferenceSystem, code: string): Promise<ReferenceCodeRecord>;
|
|
940
|
+
/**
|
|
941
|
+
* Search SNOMED CT, UMLS, or RxNorm by free-text query. JSON-backed systems
|
|
942
|
+
* (ICD-10-CM, ICD-11, ICF, LOINC) keep their per-system search endpoints
|
|
943
|
+
* (`autoicd.icd10.search`, `autoicd.icd11.search`, ...).
|
|
944
|
+
*
|
|
945
|
+
* @example
|
|
946
|
+
* ```ts
|
|
947
|
+
* const hits = await autoicd.reference.search("snomed-ct", "type 2 diabetes", { limit: 5 });
|
|
948
|
+
* for (const hit of hits.results) {
|
|
949
|
+
* console.log(hit.code, hit.label, hit.meta);
|
|
950
|
+
* }
|
|
951
|
+
* ```
|
|
952
|
+
*/
|
|
953
|
+
search(system: SearchableReferenceSystem, query: string, options?: {
|
|
954
|
+
limit?: number;
|
|
955
|
+
}): Promise<ReferenceSearchResponse>;
|
|
852
956
|
}
|
|
853
957
|
|
|
854
958
|
declare class AutoICDError extends Error {
|
|
@@ -866,4 +970,4 @@ declare class NotFoundError extends AutoICDError {
|
|
|
866
970
|
constructor(message?: string);
|
|
867
971
|
}
|
|
868
972
|
|
|
869
|
-
export { type AnonymizeResponse, type AuditCapability, type AuditCode, type AuditContext, type AuditDocument, type AuditRequest, type AuditResponse, type AuditTotals, AuthenticationError, AutoICD, AutoICDError, type AutoICDOptions, type ChapterInfo, type CodeDetail, type CodeDetailFull, type CodeMatch, type CodeOptions, type CodeSearchResponse, type CodingEntity, type CodingResponse, type ConfirmedCode, type CrosswalkMapping, type DenialRisk, type EvidenceSpan, type ICD11ChapterInfo, type ICD11CodeDetail, type ICD11CodeDetailFull, type ICD11CodeSearchResponse, type ICD11CodeSearchResult, type ICFCodeDetail, type ICFCodeResult, type ICFCodeSummary, type ICFCodingEntity, type ICFComponent, type ICFCoreSetResult, type ICFCrossReference, type ICFSearchResponse, type InteropSystem, type LOINCCodeDetail, type LOINCCodeResult, type LOINCCodeSummary, type LOINCCodingEntity, type LOINCCodingResponse, type LOINCSearchResponse, type MissedCode, NotFoundError, type PIIEntity, type ProblemListEntry, type RateLimit, RateLimitError, type RatesUsed, type ReferenceCodeRecord, type ReferenceSystem, type SearchOptions, type SpecificityUpgrade, type TranslateMapping, type TranslateRequest, type TranslateResponse, type TranslateSource, type UnsupportedCode, type UpgradeHint };
|
|
973
|
+
export { type AnonymizeResponse, type AuditCapability, type AuditCode, type AuditContext, type AuditDocument, type AuditRequest, type AuditResponse, type AuditTotals, AuthenticationError, AutoICD, AutoICDError, type AutoICDOptions, type ChapterInfo, type CodeDetail, type CodeDetailFull, type CodeMatch, type CodeOptions, type CodeSearchResponse, type CodingEntity, type CodingResponse, type ConfirmedCode, type CrosswalkMapping, type DenialRisk, type EvidenceSpan, type ICD11ChapterInfo, type ICD11CodeDetail, type ICD11CodeDetailFull, type ICD11CodeSearchResponse, type ICD11CodeSearchResult, type ICFCodeDetail, type ICFCodeResult, type ICFCodeSummary, type ICFCodingEntity, type ICFComponent, type ICFCoreSetResult, type ICFCrossReference, type ICFSearchResponse, type InteropSystem, type LOINCCodeDetail, type LOINCCodeResult, type LOINCCodeSummary, type LOINCCodingEntity, type LOINCCodingResponse, type LOINCSearchResponse, type MissedCode, NotFoundError, type PIIEntity, type ProblemListEntry, type RateLimit, RateLimitError, type RatesUsed, type ReferenceCodeRecord, type ReferenceSearchHit, type ReferenceSearchResponse, type ReferenceSystem, type RxnormCodeDetail, type SearchOptions, type SearchableReferenceSystem, type SnomedCodeDetail, type SpecificityUpgrade, type TranslateMapping, type TranslateRequest, type TranslateResponse, type TranslateSource, type UmlsAtomDetail, type UmlsCodeDetail, type UnsupportedCode, type UpgradeHint };
|
package/dist/index.js
CHANGED
|
@@ -403,6 +403,7 @@ var ReferenceCodes = class {
|
|
|
403
403
|
}
|
|
404
404
|
/**
|
|
405
405
|
* Look up canonical reference data for a code in any supported coding system.
|
|
406
|
+
* Supports ICD-10-CM, ICD-11, ICF, LOINC, SNOMED CT, UMLS, and RxNorm.
|
|
406
407
|
*
|
|
407
408
|
* Supersedes the per-system getters (`icd10.get`, `icd11.get`, `icf.lookup`,
|
|
408
409
|
* `loinc.lookup`), which remain available but emit `Deprecation` and `Sunset`
|
|
@@ -414,6 +415,11 @@ var ReferenceCodes = class {
|
|
|
414
415
|
* if (result.system === "icd-10-cm") {
|
|
415
416
|
* console.log(result.record.long_description);
|
|
416
417
|
* }
|
|
418
|
+
*
|
|
419
|
+
* const concept = await autoicd.reference.lookup("snomed-ct", "44054006");
|
|
420
|
+
* if (concept.system === "snomed-ct") {
|
|
421
|
+
* console.log(concept.record.preferred_term);
|
|
422
|
+
* }
|
|
417
423
|
* ```
|
|
418
424
|
*/
|
|
419
425
|
async lookup(system, code) {
|
|
@@ -421,6 +427,26 @@ var ReferenceCodes = class {
|
|
|
421
427
|
`/api/v1/reference/${encodeURIComponent(system)}/${encodeURIComponent(code)}`
|
|
422
428
|
);
|
|
423
429
|
}
|
|
430
|
+
/**
|
|
431
|
+
* Search SNOMED CT, UMLS, or RxNorm by free-text query. JSON-backed systems
|
|
432
|
+
* (ICD-10-CM, ICD-11, ICF, LOINC) keep their per-system search endpoints
|
|
433
|
+
* (`autoicd.icd10.search`, `autoicd.icd11.search`, ...).
|
|
434
|
+
*
|
|
435
|
+
* @example
|
|
436
|
+
* ```ts
|
|
437
|
+
* const hits = await autoicd.reference.search("snomed-ct", "type 2 diabetes", { limit: 5 });
|
|
438
|
+
* for (const hit of hits.results) {
|
|
439
|
+
* console.log(hit.code, hit.label, hit.meta);
|
|
440
|
+
* }
|
|
441
|
+
* ```
|
|
442
|
+
*/
|
|
443
|
+
async search(system, query, options) {
|
|
444
|
+
const params = new URLSearchParams({ q: query });
|
|
445
|
+
if (options?.limit !== void 0) params.set("limit", String(options.limit));
|
|
446
|
+
return this.client.get(
|
|
447
|
+
`/api/v1/reference/${encodeURIComponent(system)}/search?${params}`
|
|
448
|
+
);
|
|
449
|
+
}
|
|
424
450
|
};
|
|
425
451
|
function parseRateLimit(headers) {
|
|
426
452
|
const limit = headers.get("X-RateLimit-Limit");
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/errors.ts","../src/client.ts"],"sourcesContent":["export { AutoICD } from \"./client.js\";\n\nexport type {\n AutoICDOptions,\n CodeOptions,\n CodeMatch,\n CodingEntity,\n CodingResponse,\n SearchOptions,\n CodeDetail,\n CodeDetailFull,\n ChapterInfo,\n CodeSearchResponse,\n PIIEntity,\n AnonymizeResponse,\n RateLimit,\n ICD11CodeDetail,\n ICD11ChapterInfo,\n CrosswalkMapping,\n ICD11CodeDetailFull,\n ICD11CodeSearchResult,\n ICD11CodeSearchResponse,\n ICFComponent,\n ICFCodeSummary,\n ICFCodeDetail,\n ICFCodeResult,\n ICFCodingEntity,\n ICFSearchResponse,\n ICFCoreSetResult,\n ICFCrossReference,\n LOINCCodeSummary,\n LOINCCodeDetail,\n LOINCSearchResponse,\n LOINCCodeResult,\n LOINCCodingEntity,\n LOINCCodingResponse,\n AuditCapability,\n AuditCode,\n AuditDocument,\n AuditContext,\n AuditRequest,\n AuditResponse,\n EvidenceSpan,\n ConfirmedCode,\n MissedCode,\n UnsupportedCode,\n SpecificityUpgrade,\n DenialRisk,\n ProblemListEntry,\n AuditTotals,\n RatesUsed,\n UpgradeHint,\n InteropSystem,\n TranslateRequest,\n TranslateResponse,\n TranslateMapping,\n TranslateSource,\n ReferenceSystem,\n ReferenceCodeRecord,\n} from \"./types.js\";\n\nexport {\n AutoICDError,\n AuthenticationError,\n RateLimitError,\n NotFoundError,\n} from \"./errors.js\";\n","import type { RateLimit } from \"./types.js\";\n\nexport class AutoICDError extends Error {\n readonly status: number;\n\n constructor(status: number, message: string) {\n super(message);\n this.name = \"AutoICDError\";\n this.status = status;\n }\n}\n\nexport class AuthenticationError extends AutoICDError {\n constructor(message = \"Invalid API key\") {\n super(401, message);\n this.name = \"AuthenticationError\";\n }\n}\n\nexport class RateLimitError extends AutoICDError {\n readonly rateLimit: RateLimit;\n\n constructor(message: string, rateLimit: RateLimit) {\n super(429, message);\n this.name = \"RateLimitError\";\n this.rateLimit = rateLimit;\n }\n}\n\nexport class NotFoundError extends AutoICDError {\n constructor(message = \"Resource not found\") {\n super(404, message);\n this.name = \"NotFoundError\";\n }\n}\n","import type {\n AutoICDOptions,\n CodeOptions,\n CodingResponse,\n SearchOptions,\n CodeSearchResponse,\n CodeDetail,\n CodeDetailFull,\n AnonymizeResponse,\n RateLimit,\n ErrorBody,\n ICD11CodeSearchResponse,\n ICD11CodeDetailFull,\n ICFCodeDetail,\n ICFSearchResponse,\n ICFCoreSetResult,\n LOINCCodeDetail,\n LOINCSearchResponse,\n LOINCCodingResponse,\n AuditRequest,\n AuditResponse,\n TranslateRequest,\n TranslateResponse,\n ReferenceSystem,\n ReferenceCodeRecord,\n} from \"./types.js\";\nimport {\n AutoICDError,\n AuthenticationError,\n RateLimitError,\n NotFoundError,\n} from \"./errors.js\";\n\nconst DEFAULT_BASE_URL = \"https://autoicdapi.com\";\nconst DEFAULT_TIMEOUT = 30_000;\n\nexport class AutoICD {\n private readonly apiKey: string;\n private readonly baseURL: string;\n private readonly timeout: number;\n private readonly _fetch: typeof globalThis.fetch;\n\n /** Rate limit info from the most recent API response. */\n lastRateLimit: RateLimit | null = null;\n\n /** Sub-resource for ICD-10 code lookup. */\n readonly icd10: ICD10Codes;\n\n /** Sub-resource for ICD-11 code lookup. */\n readonly icd11: ICD11Codes;\n\n /** Sub-resource for ICF code lookup and coding. */\n readonly icf: ICFCodes;\n\n /** Sub-resource for LOINC code lookup and coding. */\n readonly loinc: LOINCCodes;\n\n /** Unified cross-system reference lookup. */\n readonly reference: ReferenceCodes;\n\n constructor(options: AutoICDOptions) {\n if (!options.apiKey) {\n throw new Error(\"apiKey is required\");\n }\n this.apiKey = options.apiKey;\n this.baseURL = (options.baseURL ?? DEFAULT_BASE_URL).replace(/\\/+$/, \"\");\n this.timeout = options.timeout ?? DEFAULT_TIMEOUT;\n this._fetch = options.fetch ?? globalThis.fetch;\n this.icd10 = new ICD10Codes(this);\n this.icd11 = new ICD11Codes(this);\n this.icf = new ICFCodes(this);\n this.loinc = new LOINCCodes(this);\n this.reference = new ReferenceCodes(this);\n }\n\n // ─── Public Methods ───\n\n /**\n * Code clinical text to ICD-10-CM diagnoses.\n *\n * @example\n * ```ts\n * const result = await autoicd.code(\"Patient has type 2 diabetes\");\n * for (const entity of result.entities) {\n * console.log(entity.entity_text, entity.codes[0]?.code);\n * }\n * ```\n */\n async code(text: string, options?: CodeOptions): Promise<CodingResponse> {\n return this.post<CodingResponse>(\"/api/v1/code\", {\n text,\n top_k: options?.topK,\n include_negated: options?.includeNegated,\n output_system: options?.outputSystem,\n include_icf: options?.includeIcf,\n include_icd11: options?.includeIcd11,\n include_snomed: options?.includeSnomed,\n include_umls: options?.includeUmls,\n });\n }\n\n /**\n * Anonymize PHI/PII in clinical text.\n *\n * @example\n * ```ts\n * const result = await autoicd.anonymize(\"John Smith, DOB 01/15/1980, has COPD\");\n * console.log(result.anonymized_text);\n * // \"[NAME], DOB [DATE], has COPD\"\n * ```\n */\n async anonymize(text: string): Promise<AnonymizeResponse> {\n return this.post<AnonymizeResponse>(\"/api/v1/anonymize\", { text });\n }\n\n /**\n * Audit a chart for coding gaps, RADV risk, specificity, denial flags, and\n * a reconciled problem list. Every finding carries extractive evidence spans.\n *\n * @example\n * ```ts\n * const audit = await autoicd.audit({\n * text: \"68yo M, type 2 diabetes, chronic systolic heart failure on furosemide.\",\n * codes: [{ code: \"E11.9\", kind: \"icd10\" }],\n * capabilities: [\"hcc\", \"radv\", \"specificity\", \"denial\", \"problem_list\"],\n * context: { patient: { coverage: \"medicare_advantage\" } },\n * });\n * console.log(audit.totals.estimated_revenue_recovery);\n * for (const m of audit.missed) {\n * console.log(`${m.code} ${m.hcc_category} $${m.estimated_revenue}`);\n * }\n * ```\n */\n async audit(request: AuditRequest): Promise<AuditResponse> {\n return this.post<AuditResponse>(\"/api/v1/audit\", request as unknown as Record<string, unknown>);\n }\n\n /**\n * Translate a code between healthcare coding systems. Maps a source code\n * (ICD-10, ICD-11, SNOMED, UMLS, ICF) to equivalents in requested target\n * systems. Omit `to` to get every system reachable from the source.\n *\n * @example\n * ```ts\n * const result = await autoicd.translate({\n * from: { code: \"E11.9\", system: \"icd10\" },\n * });\n * console.log(result.mappings.icd11);\n * console.log(result.mappings.snomed);\n * ```\n */\n async translate(request: TranslateRequest): Promise<TranslateResponse> {\n return this.post<TranslateResponse>(\n \"/api/v1/translate\",\n request as unknown as Record<string, unknown>,\n );\n }\n\n // ─── Internal HTTP ───\n\n /** @internal */\n async get<T>(path: string): Promise<T> {\n return this.request<T>(\"GET\", path);\n }\n\n /** @internal */\n async post<T>(path: string, body: Record<string, unknown>): Promise<T> {\n // Strip undefined values so the API receives clean JSON\n const clean = Object.fromEntries(\n Object.entries(body).filter(([, v]) => v !== undefined)\n );\n return this.request<T>(\"POST\", path, clean);\n }\n\n private async request<T>(\n method: string,\n path: string,\n body?: Record<string, unknown>\n ): Promise<T> {\n const url = `${this.baseURL}${path}`;\n const controller = new AbortController();\n const timer = setTimeout(() => controller.abort(), this.timeout);\n\n try {\n const res = await this._fetch(url, {\n method,\n headers: {\n Authorization: `Bearer ${this.apiKey}`,\n \"Content-Type\": \"application/json\",\n Accept: \"application/json\",\n },\n body: body ? JSON.stringify(body) : undefined,\n signal: controller.signal,\n });\n\n // Parse rate limit headers\n this.lastRateLimit = parseRateLimit(res.headers);\n\n if (res.ok) {\n return (await res.json()) as T;\n }\n\n // Error responses\n const errorBody = (await res.json().catch(() => null)) as ErrorBody | null;\n const message = errorBody?.error ?? `HTTP ${res.status}`;\n\n if (res.status === 401) throw new AuthenticationError(message);\n if (res.status === 404) throw new NotFoundError(message);\n if (res.status === 429) {\n throw new RateLimitError(\n message,\n this.lastRateLimit ?? {\n limit: errorBody?.limit ?? 0,\n remaining: 0,\n resetAt: errorBody?.resetAt ? new Date(errorBody.resetAt) : new Date(),\n }\n );\n }\n\n throw new AutoICDError(res.status, message);\n } catch (err) {\n if (err instanceof AutoICDError) throw err;\n if (err instanceof DOMException && err.name === \"AbortError\") {\n throw new AutoICDError(0, `Request timed out after ${this.timeout}ms`);\n }\n throw err;\n } finally {\n clearTimeout(timer);\n }\n }\n}\n\n// ─── ICD-10 Codes Sub-resource ───\n\nclass ICD10Codes {\n constructor(private readonly client: AutoICD) {}\n\n /**\n * Search ICD-10 codes by description.\n *\n * @example\n * ```ts\n * const results = await autoicd.icd10.search(\"diabetes mellitus\");\n * ```\n */\n async search(query: string, options?: SearchOptions): Promise<CodeSearchResponse> {\n const params = new URLSearchParams({ q: query });\n if (options?.limit !== undefined) params.set(\"limit\", String(options.limit));\n if (options?.offset !== undefined) params.set(\"offset\", String(options.offset));\n return this.client.get<CodeSearchResponse>(`/api/v1/icd10/codes/search?${params}`);\n }\n\n /**\n * Get comprehensive details for a single ICD-10 code, including synonyms,\n * hierarchy (parent/children), chapter, and SNOMED CT / UMLS cross-references.\n *\n * @example\n * ```ts\n * const detail = await autoicd.icd10.get(\"E11.9\");\n * console.log(detail.long_description);\n * console.log(detail.synonyms.snomed); // SNOMED CT synonyms\n * console.log(detail.chapter?.title); // \"Endocrine, Nutritional and Metabolic Diseases\"\n * console.log(detail.children.length); // child codes\n * ```\n */\n async get(code: string): Promise<CodeDetailFull> {\n return this.client.get<CodeDetailFull>(`/api/v1/icd10/codes/${encodeURIComponent(code)}`);\n }\n\n}\n\n// ─── ICD-11 Codes Sub-resource ───\n\nclass ICD11Codes {\n constructor(private readonly client: AutoICD) {}\n\n /**\n * Search ICD-11 codes by description.\n *\n * @example\n * ```ts\n * const results = await autoicd.icd11.search(\"diabetes mellitus\");\n * ```\n */\n async search(query: string, options?: SearchOptions): Promise<ICD11CodeSearchResponse> {\n const params = new URLSearchParams({ q: query });\n if (options?.limit !== undefined) params.set(\"limit\", String(options.limit));\n if (options?.offset !== undefined) params.set(\"offset\", String(options.offset));\n return this.client.get<ICD11CodeSearchResponse>(`/api/v1/icd11/codes/search?${params}`);\n }\n\n /**\n * Get comprehensive details for a single ICD-11 code, including synonyms,\n * hierarchy (parent/children), chapter, and ICD-10 crosswalk mappings.\n *\n * @example\n * ```ts\n * const detail = await autoicd.icd11.get(\"5A11\");\n * console.log(detail.long_description);\n * console.log(detail.chapter?.title);\n * console.log(detail.icd10_mappings);\n * ```\n */\n async get(code: string): Promise<ICD11CodeDetailFull> {\n return this.client.get<ICD11CodeDetailFull>(`/api/v1/icd11/codes/${encodeURIComponent(code)}`);\n }\n}\n\n// ─── ICF Codes Sub-resource ───\n\nclass ICFCodes {\n constructor(private readonly client: AutoICD) {}\n\n /**\n * Get full details for a single ICF code, including definition,\n * hierarchy (parent/children), inclusions, exclusions, and index terms.\n *\n * @example\n * ```ts\n * const detail = await autoicd.icf.lookup(\"b280\");\n * console.log(detail.title);\n * console.log(detail.definition);\n * console.log(detail.children.length);\n * ```\n */\n async lookup(code: string): Promise<ICFCodeDetail> {\n return this.client.get<ICFCodeDetail>(`/api/v1/icf/codes/${encodeURIComponent(code)}`);\n }\n\n /**\n * Search ICF codes by description.\n *\n * @example\n * ```ts\n * const results = await autoicd.icf.search(\"pain\");\n * ```\n */\n async search(query: string, options?: SearchOptions): Promise<ICFSearchResponse> {\n const params = new URLSearchParams({ q: query });\n if (options?.limit !== undefined) params.set(\"limit\", String(options.limit));\n if (options?.offset !== undefined) params.set(\"offset\", String(options.offset));\n return this.client.get<ICFSearchResponse>(`/api/v1/icf/codes/search?${params}`);\n }\n\n /**\n * Get the ICF Core Set for an ICD-10 diagnosis code.\n *\n * @example\n * ```ts\n * const coreSet = await autoicd.icf.coreSet(\"M54.5\");\n * console.log(coreSet.condition_name);\n * console.log(coreSet.brief.length, \"brief codes\");\n * console.log(coreSet.comprehensive.length, \"comprehensive codes\");\n * ```\n */\n async coreSet(icd10Code: string): Promise<ICFCoreSetResult> {\n return this.client.get<ICFCoreSetResult>(`/api/v1/icf/core-set/${encodeURIComponent(icd10Code)}`);\n }\n}\n\n// ─── LOINC Codes Sub-resource ───\n\nclass LOINCCodes {\n constructor(private readonly client: AutoICD) {}\n\n /**\n * Code clinical text to LOINC codes.\n *\n * Extracts lab tests, imaging orders, and clinical observations from\n * free text and matches to LOINC codes using NER + SapBERT embeddings.\n *\n * @example\n * ```ts\n * const result = await autoicd.loinc.code(\"Order CBC, glucose, and TSH\");\n * for (const entity of result.results) {\n * console.log(entity.entity_text, entity.codes[0]?.code);\n * }\n * ```\n */\n async code(text: string, options?: { topK?: number }): Promise<LOINCCodingResponse> {\n return this.client.post<LOINCCodingResponse>(\"/api/v1/loinc/code\", {\n text,\n top_k: options?.topK,\n });\n }\n\n /**\n * Get full details for a single LOINC code, including 6-axis classification,\n * definition, related names, and cross-references.\n *\n * @example\n * ```ts\n * const detail = await autoicd.loinc.lookup(\"2345-7\");\n * console.log(detail.long_common_name);\n * console.log(detail.component, detail.system);\n * ```\n */\n async lookup(code: string): Promise<LOINCCodeDetail> {\n return this.client.get<LOINCCodeDetail>(`/api/v1/loinc/codes/${encodeURIComponent(code)}`);\n }\n\n /**\n * Search LOINC codes by description.\n *\n * @example\n * ```ts\n * const results = await autoicd.loinc.search(\"glucose\");\n * ```\n */\n async search(query: string, options?: SearchOptions): Promise<LOINCSearchResponse> {\n const params = new URLSearchParams({ q: query });\n if (options?.limit !== undefined) params.set(\"limit\", String(options.limit));\n if (options?.offset !== undefined) params.set(\"offset\", String(options.offset));\n return this.client.get<LOINCSearchResponse>(`/api/v1/loinc/codes/search?${params}`);\n }\n}\n\n// ─── Reference Sub-resource ───\n\nclass ReferenceCodes {\n constructor(private readonly client: AutoICD) {}\n\n /**\n * Look up canonical reference data for a code in any supported coding system.\n *\n * Supersedes the per-system getters (`icd10.get`, `icd11.get`, `icf.lookup`,\n * `loinc.lookup`), which remain available but emit `Deprecation` and `Sunset`\n * response headers.\n *\n * @example\n * ```ts\n * const result = await autoicd.reference.lookup(\"icd-10-cm\", \"I50.23\");\n * if (result.system === \"icd-10-cm\") {\n * console.log(result.record.long_description);\n * }\n * ```\n */\n async lookup(system: ReferenceSystem, code: string): Promise<ReferenceCodeRecord> {\n return this.client.get<ReferenceCodeRecord>(\n `/api/v1/reference/${encodeURIComponent(system)}/${encodeURIComponent(code)}`\n );\n }\n}\n\n// ─── Helpers ───\n\nfunction parseRateLimit(headers: Headers): RateLimit | null {\n const limit = headers.get(\"X-RateLimit-Limit\");\n const remaining = headers.get(\"X-RateLimit-Remaining\");\n const reset = headers.get(\"X-RateLimit-Reset\");\n\n if (!limit || !remaining || !reset) return null;\n\n return {\n limit: parseInt(limit, 10),\n remaining: parseInt(remaining, 10),\n resetAt: new Date(reset),\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACEO,IAAM,eAAN,cAA2B,MAAM;AAAA,EAC7B;AAAA,EAET,YAAY,QAAgB,SAAiB;AAC3C,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,SAAS;AAAA,EAChB;AACF;AAEO,IAAM,sBAAN,cAAkC,aAAa;AAAA,EACpD,YAAY,UAAU,mBAAmB;AACvC,UAAM,KAAK,OAAO;AAClB,SAAK,OAAO;AAAA,EACd;AACF;AAEO,IAAM,iBAAN,cAA6B,aAAa;AAAA,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,WAAW,OAAW,QAAO,IAAI,UAAU,OAAO,QAAQ,MAAM,CAAC;AAC9E,WAAO,KAAK,OAAO,IAAyB,8BAA8B,MAAM,EAAE;AAAA,EACpF;AACF;AAIA,IAAM,iBAAN,MAAqB;AAAA,EACnB,YAA6B,QAAiB;AAAjB;AAAA,EAAkB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAiB/C,MAAM,OAAO,QAAyB,MAA4C;AAChF,WAAO,KAAK,OAAO;AAAA,MACjB,qBAAqB,mBAAmB,MAAM,CAAC,IAAI,mBAAmB,IAAI,CAAC;AAAA,IAC7E;AAAA,EACF;AACF;AAIA,SAAS,eAAe,SAAoC;AAC1D,QAAM,QAAQ,QAAQ,IAAI,mBAAmB;AAC7C,QAAM,YAAY,QAAQ,IAAI,uBAAuB;AACrD,QAAM,QAAQ,QAAQ,IAAI,mBAAmB;AAE7C,MAAI,CAAC,SAAS,CAAC,aAAa,CAAC,MAAO,QAAO;AAE3C,SAAO;AAAA,IACL,OAAO,SAAS,OAAO,EAAE;AAAA,IACzB,WAAW,SAAS,WAAW,EAAE;AAAA,IACjC,SAAS,IAAI,KAAK,KAAK;AAAA,EACzB;AACF;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/errors.ts","../src/client.ts"],"sourcesContent":["export { AutoICD } from \"./client.js\";\n\nexport type {\n AutoICDOptions,\n CodeOptions,\n CodeMatch,\n CodingEntity,\n CodingResponse,\n SearchOptions,\n CodeDetail,\n CodeDetailFull,\n ChapterInfo,\n CodeSearchResponse,\n PIIEntity,\n AnonymizeResponse,\n RateLimit,\n ICD11CodeDetail,\n ICD11ChapterInfo,\n CrosswalkMapping,\n ICD11CodeDetailFull,\n ICD11CodeSearchResult,\n ICD11CodeSearchResponse,\n ICFComponent,\n ICFCodeSummary,\n ICFCodeDetail,\n ICFCodeResult,\n ICFCodingEntity,\n ICFSearchResponse,\n ICFCoreSetResult,\n ICFCrossReference,\n LOINCCodeSummary,\n LOINCCodeDetail,\n LOINCSearchResponse,\n LOINCCodeResult,\n LOINCCodingEntity,\n LOINCCodingResponse,\n AuditCapability,\n AuditCode,\n AuditDocument,\n AuditContext,\n AuditRequest,\n AuditResponse,\n EvidenceSpan,\n ConfirmedCode,\n MissedCode,\n UnsupportedCode,\n SpecificityUpgrade,\n DenialRisk,\n ProblemListEntry,\n AuditTotals,\n RatesUsed,\n UpgradeHint,\n InteropSystem,\n TranslateRequest,\n TranslateResponse,\n TranslateMapping,\n TranslateSource,\n ReferenceSystem,\n ReferenceCodeRecord,\n SearchableReferenceSystem,\n ReferenceSearchHit,\n ReferenceSearchResponse,\n SnomedCodeDetail,\n UmlsAtomDetail,\n UmlsCodeDetail,\n RxnormCodeDetail,\n} from \"./types.js\";\n\nexport {\n AutoICDError,\n AuthenticationError,\n RateLimitError,\n NotFoundError,\n} from \"./errors.js\";\n","import type { RateLimit } from \"./types.js\";\n\nexport class AutoICDError extends Error {\n readonly status: number;\n\n constructor(status: number, message: string) {\n super(message);\n this.name = \"AutoICDError\";\n this.status = status;\n }\n}\n\nexport class AuthenticationError extends AutoICDError {\n constructor(message = \"Invalid API key\") {\n super(401, message);\n this.name = \"AuthenticationError\";\n }\n}\n\nexport class RateLimitError extends AutoICDError {\n readonly rateLimit: RateLimit;\n\n constructor(message: string, rateLimit: RateLimit) {\n super(429, message);\n this.name = \"RateLimitError\";\n this.rateLimit = rateLimit;\n }\n}\n\nexport class NotFoundError extends AutoICDError {\n constructor(message = \"Resource not found\") {\n super(404, message);\n this.name = \"NotFoundError\";\n }\n}\n","import type {\n AutoICDOptions,\n CodeOptions,\n CodingResponse,\n SearchOptions,\n CodeSearchResponse,\n CodeDetail,\n CodeDetailFull,\n AnonymizeResponse,\n RateLimit,\n ErrorBody,\n ICD11CodeSearchResponse,\n ICD11CodeDetailFull,\n ICFCodeDetail,\n ICFSearchResponse,\n ICFCoreSetResult,\n LOINCCodeDetail,\n LOINCSearchResponse,\n LOINCCodingResponse,\n AuditRequest,\n AuditResponse,\n TranslateRequest,\n TranslateResponse,\n ReferenceSystem,\n ReferenceCodeRecord,\n SearchableReferenceSystem,\n ReferenceSearchResponse,\n} from \"./types.js\";\nimport {\n AutoICDError,\n AuthenticationError,\n RateLimitError,\n NotFoundError,\n} from \"./errors.js\";\n\nconst DEFAULT_BASE_URL = \"https://autoicdapi.com\";\nconst DEFAULT_TIMEOUT = 30_000;\n\nexport class AutoICD {\n private readonly apiKey: string;\n private readonly baseURL: string;\n private readonly timeout: number;\n private readonly _fetch: typeof globalThis.fetch;\n\n /** Rate limit info from the most recent API response. */\n lastRateLimit: RateLimit | null = null;\n\n /** Sub-resource for ICD-10 code lookup. */\n readonly icd10: ICD10Codes;\n\n /** Sub-resource for ICD-11 code lookup. */\n readonly icd11: ICD11Codes;\n\n /** Sub-resource for ICF code lookup and coding. */\n readonly icf: ICFCodes;\n\n /** Sub-resource for LOINC code lookup and coding. */\n readonly loinc: LOINCCodes;\n\n /** Unified cross-system reference lookup. */\n readonly reference: ReferenceCodes;\n\n constructor(options: AutoICDOptions) {\n if (!options.apiKey) {\n throw new Error(\"apiKey is required\");\n }\n this.apiKey = options.apiKey;\n this.baseURL = (options.baseURL ?? DEFAULT_BASE_URL).replace(/\\/+$/, \"\");\n this.timeout = options.timeout ?? DEFAULT_TIMEOUT;\n this._fetch = options.fetch ?? globalThis.fetch;\n this.icd10 = new ICD10Codes(this);\n this.icd11 = new ICD11Codes(this);\n this.icf = new ICFCodes(this);\n this.loinc = new LOINCCodes(this);\n this.reference = new ReferenceCodes(this);\n }\n\n // ─── Public Methods ───\n\n /**\n * Code clinical text to ICD-10-CM diagnoses.\n *\n * @example\n * ```ts\n * const result = await autoicd.code(\"Patient has type 2 diabetes\");\n * for (const entity of result.entities) {\n * console.log(entity.entity_text, entity.codes[0]?.code);\n * }\n * ```\n */\n async code(text: string, options?: CodeOptions): Promise<CodingResponse> {\n return this.post<CodingResponse>(\"/api/v1/code\", {\n text,\n top_k: options?.topK,\n include_negated: options?.includeNegated,\n output_system: options?.outputSystem,\n include_icf: options?.includeIcf,\n include_icd11: options?.includeIcd11,\n include_snomed: options?.includeSnomed,\n include_umls: options?.includeUmls,\n });\n }\n\n /**\n * Anonymize PHI/PII in clinical text.\n *\n * @example\n * ```ts\n * const result = await autoicd.anonymize(\"John Smith, DOB 01/15/1980, has COPD\");\n * console.log(result.anonymized_text);\n * // \"[NAME], DOB [DATE], has COPD\"\n * ```\n */\n async anonymize(text: string): Promise<AnonymizeResponse> {\n return this.post<AnonymizeResponse>(\"/api/v1/anonymize\", { text });\n }\n\n /**\n * Audit a chart for coding gaps, RADV risk, specificity, denial flags, and\n * a reconciled problem list. Every finding carries extractive evidence spans.\n *\n * @example\n * ```ts\n * const audit = await autoicd.audit({\n * text: \"68yo M, type 2 diabetes, chronic systolic heart failure on furosemide.\",\n * codes: [{ code: \"E11.9\", kind: \"icd10\" }],\n * capabilities: [\"hcc\", \"radv\", \"specificity\", \"denial\", \"problem_list\"],\n * context: { patient: { coverage: \"medicare_advantage\" } },\n * });\n * console.log(audit.totals.estimated_revenue_recovery);\n * for (const m of audit.missed) {\n * console.log(`${m.code} ${m.hcc_category} $${m.estimated_revenue}`);\n * }\n * ```\n */\n async audit(request: AuditRequest): Promise<AuditResponse> {\n return this.post<AuditResponse>(\"/api/v1/audit\", request as unknown as Record<string, unknown>);\n }\n\n /**\n * Translate a code between healthcare coding systems. Maps a source code\n * (ICD-10, ICD-11, SNOMED, UMLS, ICF) to equivalents in requested target\n * systems. Omit `to` to get every system reachable from the source.\n *\n * @example\n * ```ts\n * const result = await autoicd.translate({\n * from: { code: \"E11.9\", system: \"icd10\" },\n * });\n * console.log(result.mappings.icd11);\n * console.log(result.mappings.snomed);\n * ```\n */\n async translate(request: TranslateRequest): Promise<TranslateResponse> {\n return this.post<TranslateResponse>(\n \"/api/v1/translate\",\n request as unknown as Record<string, unknown>,\n );\n }\n\n // ─── Internal HTTP ───\n\n /** @internal */\n async get<T>(path: string): Promise<T> {\n return this.request<T>(\"GET\", path);\n }\n\n /** @internal */\n async post<T>(path: string, body: Record<string, unknown>): Promise<T> {\n // Strip undefined values so the API receives clean JSON\n const clean = Object.fromEntries(\n Object.entries(body).filter(([, v]) => v !== undefined)\n );\n return this.request<T>(\"POST\", path, clean);\n }\n\n private async request<T>(\n method: string,\n path: string,\n body?: Record<string, unknown>\n ): Promise<T> {\n const url = `${this.baseURL}${path}`;\n const controller = new AbortController();\n const timer = setTimeout(() => controller.abort(), this.timeout);\n\n try {\n const res = await this._fetch(url, {\n method,\n headers: {\n Authorization: `Bearer ${this.apiKey}`,\n \"Content-Type\": \"application/json\",\n Accept: \"application/json\",\n },\n body: body ? JSON.stringify(body) : undefined,\n signal: controller.signal,\n });\n\n // Parse rate limit headers\n this.lastRateLimit = parseRateLimit(res.headers);\n\n if (res.ok) {\n return (await res.json()) as T;\n }\n\n // Error responses\n const errorBody = (await res.json().catch(() => null)) as ErrorBody | null;\n const message = errorBody?.error ?? `HTTP ${res.status}`;\n\n if (res.status === 401) throw new AuthenticationError(message);\n if (res.status === 404) throw new NotFoundError(message);\n if (res.status === 429) {\n throw new RateLimitError(\n message,\n this.lastRateLimit ?? {\n limit: errorBody?.limit ?? 0,\n remaining: 0,\n resetAt: errorBody?.resetAt ? new Date(errorBody.resetAt) : new Date(),\n }\n );\n }\n\n throw new AutoICDError(res.status, message);\n } catch (err) {\n if (err instanceof AutoICDError) throw err;\n if (err instanceof DOMException && err.name === \"AbortError\") {\n throw new AutoICDError(0, `Request timed out after ${this.timeout}ms`);\n }\n throw err;\n } finally {\n clearTimeout(timer);\n }\n }\n}\n\n// ─── ICD-10 Codes Sub-resource ───\n\nclass ICD10Codes {\n constructor(private readonly client: AutoICD) {}\n\n /**\n * Search ICD-10 codes by description.\n *\n * @example\n * ```ts\n * const results = await autoicd.icd10.search(\"diabetes mellitus\");\n * ```\n */\n async search(query: string, options?: SearchOptions): Promise<CodeSearchResponse> {\n const params = new URLSearchParams({ q: query });\n if (options?.limit !== undefined) params.set(\"limit\", String(options.limit));\n if (options?.offset !== undefined) params.set(\"offset\", String(options.offset));\n return this.client.get<CodeSearchResponse>(`/api/v1/icd10/codes/search?${params}`);\n }\n\n /**\n * Get comprehensive details for a single ICD-10 code, including synonyms,\n * hierarchy (parent/children), chapter, and SNOMED CT / UMLS cross-references.\n *\n * @example\n * ```ts\n * const detail = await autoicd.icd10.get(\"E11.9\");\n * console.log(detail.long_description);\n * console.log(detail.synonyms.snomed); // SNOMED CT synonyms\n * console.log(detail.chapter?.title); // \"Endocrine, Nutritional and Metabolic Diseases\"\n * console.log(detail.children.length); // child codes\n * ```\n */\n async get(code: string): Promise<CodeDetailFull> {\n return this.client.get<CodeDetailFull>(`/api/v1/icd10/codes/${encodeURIComponent(code)}`);\n }\n\n}\n\n// ─── ICD-11 Codes Sub-resource ───\n\nclass ICD11Codes {\n constructor(private readonly client: AutoICD) {}\n\n /**\n * Search ICD-11 codes by description.\n *\n * @example\n * ```ts\n * const results = await autoicd.icd11.search(\"diabetes mellitus\");\n * ```\n */\n async search(query: string, options?: SearchOptions): Promise<ICD11CodeSearchResponse> {\n const params = new URLSearchParams({ q: query });\n if (options?.limit !== undefined) params.set(\"limit\", String(options.limit));\n if (options?.offset !== undefined) params.set(\"offset\", String(options.offset));\n return this.client.get<ICD11CodeSearchResponse>(`/api/v1/icd11/codes/search?${params}`);\n }\n\n /**\n * Get comprehensive details for a single ICD-11 code, including synonyms,\n * hierarchy (parent/children), chapter, and ICD-10 crosswalk mappings.\n *\n * @example\n * ```ts\n * const detail = await autoicd.icd11.get(\"5A11\");\n * console.log(detail.long_description);\n * console.log(detail.chapter?.title);\n * console.log(detail.icd10_mappings);\n * ```\n */\n async get(code: string): Promise<ICD11CodeDetailFull> {\n return this.client.get<ICD11CodeDetailFull>(`/api/v1/icd11/codes/${encodeURIComponent(code)}`);\n }\n}\n\n// ─── ICF Codes Sub-resource ───\n\nclass ICFCodes {\n constructor(private readonly client: AutoICD) {}\n\n /**\n * Get full details for a single ICF code, including definition,\n * hierarchy (parent/children), inclusions, exclusions, and index terms.\n *\n * @example\n * ```ts\n * const detail = await autoicd.icf.lookup(\"b280\");\n * console.log(detail.title);\n * console.log(detail.definition);\n * console.log(detail.children.length);\n * ```\n */\n async lookup(code: string): Promise<ICFCodeDetail> {\n return this.client.get<ICFCodeDetail>(`/api/v1/icf/codes/${encodeURIComponent(code)}`);\n }\n\n /**\n * Search ICF codes by description.\n *\n * @example\n * ```ts\n * const results = await autoicd.icf.search(\"pain\");\n * ```\n */\n async search(query: string, options?: SearchOptions): Promise<ICFSearchResponse> {\n const params = new URLSearchParams({ q: query });\n if (options?.limit !== undefined) params.set(\"limit\", String(options.limit));\n if (options?.offset !== undefined) params.set(\"offset\", String(options.offset));\n return this.client.get<ICFSearchResponse>(`/api/v1/icf/codes/search?${params}`);\n }\n\n /**\n * Get the ICF Core Set for an ICD-10 diagnosis code.\n *\n * @example\n * ```ts\n * const coreSet = await autoicd.icf.coreSet(\"M54.5\");\n * console.log(coreSet.condition_name);\n * console.log(coreSet.brief.length, \"brief codes\");\n * console.log(coreSet.comprehensive.length, \"comprehensive codes\");\n * ```\n */\n async coreSet(icd10Code: string): Promise<ICFCoreSetResult> {\n return this.client.get<ICFCoreSetResult>(`/api/v1/icf/core-set/${encodeURIComponent(icd10Code)}`);\n }\n}\n\n// ─── LOINC Codes Sub-resource ───\n\nclass LOINCCodes {\n constructor(private readonly client: AutoICD) {}\n\n /**\n * Code clinical text to LOINC codes.\n *\n * Extracts lab tests, imaging orders, and clinical observations from\n * free text and matches to LOINC codes using NER + SapBERT embeddings.\n *\n * @example\n * ```ts\n * const result = await autoicd.loinc.code(\"Order CBC, glucose, and TSH\");\n * for (const entity of result.results) {\n * console.log(entity.entity_text, entity.codes[0]?.code);\n * }\n * ```\n */\n async code(text: string, options?: { topK?: number }): Promise<LOINCCodingResponse> {\n return this.client.post<LOINCCodingResponse>(\"/api/v1/loinc/code\", {\n text,\n top_k: options?.topK,\n });\n }\n\n /**\n * Get full details for a single LOINC code, including 6-axis classification,\n * definition, related names, and cross-references.\n *\n * @example\n * ```ts\n * const detail = await autoicd.loinc.lookup(\"2345-7\");\n * console.log(detail.long_common_name);\n * console.log(detail.component, detail.system);\n * ```\n */\n async lookup(code: string): Promise<LOINCCodeDetail> {\n return this.client.get<LOINCCodeDetail>(`/api/v1/loinc/codes/${encodeURIComponent(code)}`);\n }\n\n /**\n * Search LOINC codes by description.\n *\n * @example\n * ```ts\n * const results = await autoicd.loinc.search(\"glucose\");\n * ```\n */\n async search(query: string, options?: SearchOptions): Promise<LOINCSearchResponse> {\n const params = new URLSearchParams({ q: query });\n if (options?.limit !== undefined) params.set(\"limit\", String(options.limit));\n if (options?.offset !== undefined) params.set(\"offset\", String(options.offset));\n return this.client.get<LOINCSearchResponse>(`/api/v1/loinc/codes/search?${params}`);\n }\n}\n\n// ─── Reference Sub-resource ───\n\nclass ReferenceCodes {\n constructor(private readonly client: AutoICD) {}\n\n /**\n * Look up canonical reference data for a code in any supported coding system.\n * Supports ICD-10-CM, ICD-11, ICF, LOINC, SNOMED CT, UMLS, and RxNorm.\n *\n * Supersedes the per-system getters (`icd10.get`, `icd11.get`, `icf.lookup`,\n * `loinc.lookup`), which remain available but emit `Deprecation` and `Sunset`\n * response headers.\n *\n * @example\n * ```ts\n * const result = await autoicd.reference.lookup(\"icd-10-cm\", \"I50.23\");\n * if (result.system === \"icd-10-cm\") {\n * console.log(result.record.long_description);\n * }\n *\n * const concept = await autoicd.reference.lookup(\"snomed-ct\", \"44054006\");\n * if (concept.system === \"snomed-ct\") {\n * console.log(concept.record.preferred_term);\n * }\n * ```\n */\n async lookup(system: ReferenceSystem, code: string): Promise<ReferenceCodeRecord> {\n return this.client.get<ReferenceCodeRecord>(\n `/api/v1/reference/${encodeURIComponent(system)}/${encodeURIComponent(code)}`\n );\n }\n\n /**\n * Search SNOMED CT, UMLS, or RxNorm by free-text query. JSON-backed systems\n * (ICD-10-CM, ICD-11, ICF, LOINC) keep their per-system search endpoints\n * (`autoicd.icd10.search`, `autoicd.icd11.search`, ...).\n *\n * @example\n * ```ts\n * const hits = await autoicd.reference.search(\"snomed-ct\", \"type 2 diabetes\", { limit: 5 });\n * for (const hit of hits.results) {\n * console.log(hit.code, hit.label, hit.meta);\n * }\n * ```\n */\n async search(\n system: SearchableReferenceSystem,\n query: string,\n options?: { limit?: number },\n ): Promise<ReferenceSearchResponse> {\n const params = new URLSearchParams({ q: query });\n if (options?.limit !== undefined) params.set(\"limit\", String(options.limit));\n return this.client.get<ReferenceSearchResponse>(\n `/api/v1/reference/${encodeURIComponent(system)}/search?${params}`,\n );\n }\n}\n\n// ─── Helpers ───\n\nfunction parseRateLimit(headers: Headers): RateLimit | null {\n const limit = headers.get(\"X-RateLimit-Limit\");\n const remaining = headers.get(\"X-RateLimit-Remaining\");\n const reset = headers.get(\"X-RateLimit-Reset\");\n\n if (!limit || !remaining || !reset) return null;\n\n return {\n limit: parseInt(limit, 10),\n remaining: parseInt(remaining, 10),\n resetAt: new Date(reset),\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACEO,IAAM,eAAN,cAA2B,MAAM;AAAA,EAC7B;AAAA,EAET,YAAY,QAAgB,SAAiB;AAC3C,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,SAAS;AAAA,EAChB;AACF;AAEO,IAAM,sBAAN,cAAkC,aAAa;AAAA,EACpD,YAAY,UAAU,mBAAmB;AACvC,UAAM,KAAK,OAAO;AAClB,SAAK,OAAO;AAAA,EACd;AACF;AAEO,IAAM,iBAAN,cAA6B,aAAa;AAAA,EACtC;AAAA,EAET,YAAY,SAAiB,WAAsB;AACjD,UAAM,KAAK,OAAO;AAClB,SAAK,OAAO;AACZ,SAAK,YAAY;AAAA,EACnB;AACF;AAEO,IAAM,gBAAN,cAA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,iBAAN,MAAqB;AAAA,EACnB,YAA6B,QAAiB;AAAjB;AAAA,EAAkB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAuB/C,MAAM,OAAO,QAAyB,MAA4C;AAChF,WAAO,KAAK,OAAO;AAAA,MACjB,qBAAqB,mBAAmB,MAAM,CAAC,IAAI,mBAAmB,IAAI,CAAC;AAAA,IAC7E;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAeA,MAAM,OACJ,QACA,OACA,SACkC;AAClC,UAAM,SAAS,IAAI,gBAAgB,EAAE,GAAG,MAAM,CAAC;AAC/C,QAAI,SAAS,UAAU,OAAW,QAAO,IAAI,SAAS,OAAO,QAAQ,KAAK,CAAC;AAC3E,WAAO,KAAK,OAAO;AAAA,MACjB,qBAAqB,mBAAmB,MAAM,CAAC,WAAW,MAAM;AAAA,IAClE;AAAA,EACF;AACF;AAIA,SAAS,eAAe,SAAoC;AAC1D,QAAM,QAAQ,QAAQ,IAAI,mBAAmB;AAC7C,QAAM,YAAY,QAAQ,IAAI,uBAAuB;AACrD,QAAM,QAAQ,QAAQ,IAAI,mBAAmB;AAE7C,MAAI,CAAC,SAAS,CAAC,aAAa,CAAC,MAAO,QAAO;AAE3C,SAAO;AAAA,IACL,OAAO,SAAS,OAAO,EAAE;AAAA,IACzB,WAAW,SAAS,WAAW,EAAE;AAAA,IACjC,SAAS,IAAI,KAAK,KAAK;AAAA,EACzB;AACF;","names":[]}
|
package/dist/index.mjs
CHANGED
|
@@ -373,6 +373,7 @@ var ReferenceCodes = class {
|
|
|
373
373
|
}
|
|
374
374
|
/**
|
|
375
375
|
* Look up canonical reference data for a code in any supported coding system.
|
|
376
|
+
* Supports ICD-10-CM, ICD-11, ICF, LOINC, SNOMED CT, UMLS, and RxNorm.
|
|
376
377
|
*
|
|
377
378
|
* Supersedes the per-system getters (`icd10.get`, `icd11.get`, `icf.lookup`,
|
|
378
379
|
* `loinc.lookup`), which remain available but emit `Deprecation` and `Sunset`
|
|
@@ -384,6 +385,11 @@ var ReferenceCodes = class {
|
|
|
384
385
|
* if (result.system === "icd-10-cm") {
|
|
385
386
|
* console.log(result.record.long_description);
|
|
386
387
|
* }
|
|
388
|
+
*
|
|
389
|
+
* const concept = await autoicd.reference.lookup("snomed-ct", "44054006");
|
|
390
|
+
* if (concept.system === "snomed-ct") {
|
|
391
|
+
* console.log(concept.record.preferred_term);
|
|
392
|
+
* }
|
|
387
393
|
* ```
|
|
388
394
|
*/
|
|
389
395
|
async lookup(system, code) {
|
|
@@ -391,6 +397,26 @@ var ReferenceCodes = class {
|
|
|
391
397
|
`/api/v1/reference/${encodeURIComponent(system)}/${encodeURIComponent(code)}`
|
|
392
398
|
);
|
|
393
399
|
}
|
|
400
|
+
/**
|
|
401
|
+
* Search SNOMED CT, UMLS, or RxNorm by free-text query. JSON-backed systems
|
|
402
|
+
* (ICD-10-CM, ICD-11, ICF, LOINC) keep their per-system search endpoints
|
|
403
|
+
* (`autoicd.icd10.search`, `autoicd.icd11.search`, ...).
|
|
404
|
+
*
|
|
405
|
+
* @example
|
|
406
|
+
* ```ts
|
|
407
|
+
* const hits = await autoicd.reference.search("snomed-ct", "type 2 diabetes", { limit: 5 });
|
|
408
|
+
* for (const hit of hits.results) {
|
|
409
|
+
* console.log(hit.code, hit.label, hit.meta);
|
|
410
|
+
* }
|
|
411
|
+
* ```
|
|
412
|
+
*/
|
|
413
|
+
async search(system, query, options) {
|
|
414
|
+
const params = new URLSearchParams({ q: query });
|
|
415
|
+
if (options?.limit !== void 0) params.set("limit", String(options.limit));
|
|
416
|
+
return this.client.get(
|
|
417
|
+
`/api/v1/reference/${encodeURIComponent(system)}/search?${params}`
|
|
418
|
+
);
|
|
419
|
+
}
|
|
394
420
|
};
|
|
395
421
|
function parseRateLimit(headers) {
|
|
396
422
|
const limit = headers.get("X-RateLimit-Limit");
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/errors.ts","../src/client.ts"],"sourcesContent":["import type { RateLimit } from \"./types.js\";\n\nexport class AutoICDError extends Error {\n readonly status: number;\n\n constructor(status: number, message: string) {\n super(message);\n this.name = \"AutoICDError\";\n this.status = status;\n }\n}\n\nexport class AuthenticationError extends AutoICDError {\n constructor(message = \"Invalid API key\") {\n super(401, message);\n this.name = \"AuthenticationError\";\n }\n}\n\nexport class RateLimitError extends AutoICDError {\n readonly rateLimit: RateLimit;\n\n constructor(message: string, rateLimit: RateLimit) {\n super(429, message);\n this.name = \"RateLimitError\";\n this.rateLimit = rateLimit;\n }\n}\n\nexport class NotFoundError extends AutoICDError {\n constructor(message = \"Resource not found\") {\n super(404, message);\n this.name = \"NotFoundError\";\n }\n}\n","import type {\n AutoICDOptions,\n CodeOptions,\n CodingResponse,\n SearchOptions,\n CodeSearchResponse,\n CodeDetail,\n CodeDetailFull,\n AnonymizeResponse,\n RateLimit,\n ErrorBody,\n ICD11CodeSearchResponse,\n ICD11CodeDetailFull,\n ICFCodeDetail,\n ICFSearchResponse,\n ICFCoreSetResult,\n LOINCCodeDetail,\n LOINCSearchResponse,\n LOINCCodingResponse,\n AuditRequest,\n AuditResponse,\n TranslateRequest,\n TranslateResponse,\n ReferenceSystem,\n ReferenceCodeRecord,\n} from \"./types.js\";\nimport {\n AutoICDError,\n AuthenticationError,\n RateLimitError,\n NotFoundError,\n} from \"./errors.js\";\n\nconst DEFAULT_BASE_URL = \"https://autoicdapi.com\";\nconst DEFAULT_TIMEOUT = 30_000;\n\nexport class AutoICD {\n private readonly apiKey: string;\n private readonly baseURL: string;\n private readonly timeout: number;\n private readonly _fetch: typeof globalThis.fetch;\n\n /** Rate limit info from the most recent API response. */\n lastRateLimit: RateLimit | null = null;\n\n /** Sub-resource for ICD-10 code lookup. */\n readonly icd10: ICD10Codes;\n\n /** Sub-resource for ICD-11 code lookup. */\n readonly icd11: ICD11Codes;\n\n /** Sub-resource for ICF code lookup and coding. */\n readonly icf: ICFCodes;\n\n /** Sub-resource for LOINC code lookup and coding. */\n readonly loinc: LOINCCodes;\n\n /** Unified cross-system reference lookup. */\n readonly reference: ReferenceCodes;\n\n constructor(options: AutoICDOptions) {\n if (!options.apiKey) {\n throw new Error(\"apiKey is required\");\n }\n this.apiKey = options.apiKey;\n this.baseURL = (options.baseURL ?? DEFAULT_BASE_URL).replace(/\\/+$/, \"\");\n this.timeout = options.timeout ?? DEFAULT_TIMEOUT;\n this._fetch = options.fetch ?? globalThis.fetch;\n this.icd10 = new ICD10Codes(this);\n this.icd11 = new ICD11Codes(this);\n this.icf = new ICFCodes(this);\n this.loinc = new LOINCCodes(this);\n this.reference = new ReferenceCodes(this);\n }\n\n // ─── Public Methods ───\n\n /**\n * Code clinical text to ICD-10-CM diagnoses.\n *\n * @example\n * ```ts\n * const result = await autoicd.code(\"Patient has type 2 diabetes\");\n * for (const entity of result.entities) {\n * console.log(entity.entity_text, entity.codes[0]?.code);\n * }\n * ```\n */\n async code(text: string, options?: CodeOptions): Promise<CodingResponse> {\n return this.post<CodingResponse>(\"/api/v1/code\", {\n text,\n top_k: options?.topK,\n include_negated: options?.includeNegated,\n output_system: options?.outputSystem,\n include_icf: options?.includeIcf,\n include_icd11: options?.includeIcd11,\n include_snomed: options?.includeSnomed,\n include_umls: options?.includeUmls,\n });\n }\n\n /**\n * Anonymize PHI/PII in clinical text.\n *\n * @example\n * ```ts\n * const result = await autoicd.anonymize(\"John Smith, DOB 01/15/1980, has COPD\");\n * console.log(result.anonymized_text);\n * // \"[NAME], DOB [DATE], has COPD\"\n * ```\n */\n async anonymize(text: string): Promise<AnonymizeResponse> {\n return this.post<AnonymizeResponse>(\"/api/v1/anonymize\", { text });\n }\n\n /**\n * Audit a chart for coding gaps, RADV risk, specificity, denial flags, and\n * a reconciled problem list. Every finding carries extractive evidence spans.\n *\n * @example\n * ```ts\n * const audit = await autoicd.audit({\n * text: \"68yo M, type 2 diabetes, chronic systolic heart failure on furosemide.\",\n * codes: [{ code: \"E11.9\", kind: \"icd10\" }],\n * capabilities: [\"hcc\", \"radv\", \"specificity\", \"denial\", \"problem_list\"],\n * context: { patient: { coverage: \"medicare_advantage\" } },\n * });\n * console.log(audit.totals.estimated_revenue_recovery);\n * for (const m of audit.missed) {\n * console.log(`${m.code} ${m.hcc_category} $${m.estimated_revenue}`);\n * }\n * ```\n */\n async audit(request: AuditRequest): Promise<AuditResponse> {\n return this.post<AuditResponse>(\"/api/v1/audit\", request as unknown as Record<string, unknown>);\n }\n\n /**\n * Translate a code between healthcare coding systems. Maps a source code\n * (ICD-10, ICD-11, SNOMED, UMLS, ICF) to equivalents in requested target\n * systems. Omit `to` to get every system reachable from the source.\n *\n * @example\n * ```ts\n * const result = await autoicd.translate({\n * from: { code: \"E11.9\", system: \"icd10\" },\n * });\n * console.log(result.mappings.icd11);\n * console.log(result.mappings.snomed);\n * ```\n */\n async translate(request: TranslateRequest): Promise<TranslateResponse> {\n return this.post<TranslateResponse>(\n \"/api/v1/translate\",\n request as unknown as Record<string, unknown>,\n );\n }\n\n // ─── Internal HTTP ───\n\n /** @internal */\n async get<T>(path: string): Promise<T> {\n return this.request<T>(\"GET\", path);\n }\n\n /** @internal */\n async post<T>(path: string, body: Record<string, unknown>): Promise<T> {\n // Strip undefined values so the API receives clean JSON\n const clean = Object.fromEntries(\n Object.entries(body).filter(([, v]) => v !== undefined)\n );\n return this.request<T>(\"POST\", path, clean);\n }\n\n private async request<T>(\n method: string,\n path: string,\n body?: Record<string, unknown>\n ): Promise<T> {\n const url = `${this.baseURL}${path}`;\n const controller = new AbortController();\n const timer = setTimeout(() => controller.abort(), this.timeout);\n\n try {\n const res = await this._fetch(url, {\n method,\n headers: {\n Authorization: `Bearer ${this.apiKey}`,\n \"Content-Type\": \"application/json\",\n Accept: \"application/json\",\n },\n body: body ? JSON.stringify(body) : undefined,\n signal: controller.signal,\n });\n\n // Parse rate limit headers\n this.lastRateLimit = parseRateLimit(res.headers);\n\n if (res.ok) {\n return (await res.json()) as T;\n }\n\n // Error responses\n const errorBody = (await res.json().catch(() => null)) as ErrorBody | null;\n const message = errorBody?.error ?? `HTTP ${res.status}`;\n\n if (res.status === 401) throw new AuthenticationError(message);\n if (res.status === 404) throw new NotFoundError(message);\n if (res.status === 429) {\n throw new RateLimitError(\n message,\n this.lastRateLimit ?? {\n limit: errorBody?.limit ?? 0,\n remaining: 0,\n resetAt: errorBody?.resetAt ? new Date(errorBody.resetAt) : new Date(),\n }\n );\n }\n\n throw new AutoICDError(res.status, message);\n } catch (err) {\n if (err instanceof AutoICDError) throw err;\n if (err instanceof DOMException && err.name === \"AbortError\") {\n throw new AutoICDError(0, `Request timed out after ${this.timeout}ms`);\n }\n throw err;\n } finally {\n clearTimeout(timer);\n }\n }\n}\n\n// ─── ICD-10 Codes Sub-resource ───\n\nclass ICD10Codes {\n constructor(private readonly client: AutoICD) {}\n\n /**\n * Search ICD-10 codes by description.\n *\n * @example\n * ```ts\n * const results = await autoicd.icd10.search(\"diabetes mellitus\");\n * ```\n */\n async search(query: string, options?: SearchOptions): Promise<CodeSearchResponse> {\n const params = new URLSearchParams({ q: query });\n if (options?.limit !== undefined) params.set(\"limit\", String(options.limit));\n if (options?.offset !== undefined) params.set(\"offset\", String(options.offset));\n return this.client.get<CodeSearchResponse>(`/api/v1/icd10/codes/search?${params}`);\n }\n\n /**\n * Get comprehensive details for a single ICD-10 code, including synonyms,\n * hierarchy (parent/children), chapter, and SNOMED CT / UMLS cross-references.\n *\n * @example\n * ```ts\n * const detail = await autoicd.icd10.get(\"E11.9\");\n * console.log(detail.long_description);\n * console.log(detail.synonyms.snomed); // SNOMED CT synonyms\n * console.log(detail.chapter?.title); // \"Endocrine, Nutritional and Metabolic Diseases\"\n * console.log(detail.children.length); // child codes\n * ```\n */\n async get(code: string): Promise<CodeDetailFull> {\n return this.client.get<CodeDetailFull>(`/api/v1/icd10/codes/${encodeURIComponent(code)}`);\n }\n\n}\n\n// ─── ICD-11 Codes Sub-resource ───\n\nclass ICD11Codes {\n constructor(private readonly client: AutoICD) {}\n\n /**\n * Search ICD-11 codes by description.\n *\n * @example\n * ```ts\n * const results = await autoicd.icd11.search(\"diabetes mellitus\");\n * ```\n */\n async search(query: string, options?: SearchOptions): Promise<ICD11CodeSearchResponse> {\n const params = new URLSearchParams({ q: query });\n if (options?.limit !== undefined) params.set(\"limit\", String(options.limit));\n if (options?.offset !== undefined) params.set(\"offset\", String(options.offset));\n return this.client.get<ICD11CodeSearchResponse>(`/api/v1/icd11/codes/search?${params}`);\n }\n\n /**\n * Get comprehensive details for a single ICD-11 code, including synonyms,\n * hierarchy (parent/children), chapter, and ICD-10 crosswalk mappings.\n *\n * @example\n * ```ts\n * const detail = await autoicd.icd11.get(\"5A11\");\n * console.log(detail.long_description);\n * console.log(detail.chapter?.title);\n * console.log(detail.icd10_mappings);\n * ```\n */\n async get(code: string): Promise<ICD11CodeDetailFull> {\n return this.client.get<ICD11CodeDetailFull>(`/api/v1/icd11/codes/${encodeURIComponent(code)}`);\n }\n}\n\n// ─── ICF Codes Sub-resource ───\n\nclass ICFCodes {\n constructor(private readonly client: AutoICD) {}\n\n /**\n * Get full details for a single ICF code, including definition,\n * hierarchy (parent/children), inclusions, exclusions, and index terms.\n *\n * @example\n * ```ts\n * const detail = await autoicd.icf.lookup(\"b280\");\n * console.log(detail.title);\n * console.log(detail.definition);\n * console.log(detail.children.length);\n * ```\n */\n async lookup(code: string): Promise<ICFCodeDetail> {\n return this.client.get<ICFCodeDetail>(`/api/v1/icf/codes/${encodeURIComponent(code)}`);\n }\n\n /**\n * Search ICF codes by description.\n *\n * @example\n * ```ts\n * const results = await autoicd.icf.search(\"pain\");\n * ```\n */\n async search(query: string, options?: SearchOptions): Promise<ICFSearchResponse> {\n const params = new URLSearchParams({ q: query });\n if (options?.limit !== undefined) params.set(\"limit\", String(options.limit));\n if (options?.offset !== undefined) params.set(\"offset\", String(options.offset));\n return this.client.get<ICFSearchResponse>(`/api/v1/icf/codes/search?${params}`);\n }\n\n /**\n * Get the ICF Core Set for an ICD-10 diagnosis code.\n *\n * @example\n * ```ts\n * const coreSet = await autoicd.icf.coreSet(\"M54.5\");\n * console.log(coreSet.condition_name);\n * console.log(coreSet.brief.length, \"brief codes\");\n * console.log(coreSet.comprehensive.length, \"comprehensive codes\");\n * ```\n */\n async coreSet(icd10Code: string): Promise<ICFCoreSetResult> {\n return this.client.get<ICFCoreSetResult>(`/api/v1/icf/core-set/${encodeURIComponent(icd10Code)}`);\n }\n}\n\n// ─── LOINC Codes Sub-resource ───\n\nclass LOINCCodes {\n constructor(private readonly client: AutoICD) {}\n\n /**\n * Code clinical text to LOINC codes.\n *\n * Extracts lab tests, imaging orders, and clinical observations from\n * free text and matches to LOINC codes using NER + SapBERT embeddings.\n *\n * @example\n * ```ts\n * const result = await autoicd.loinc.code(\"Order CBC, glucose, and TSH\");\n * for (const entity of result.results) {\n * console.log(entity.entity_text, entity.codes[0]?.code);\n * }\n * ```\n */\n async code(text: string, options?: { topK?: number }): Promise<LOINCCodingResponse> {\n return this.client.post<LOINCCodingResponse>(\"/api/v1/loinc/code\", {\n text,\n top_k: options?.topK,\n });\n }\n\n /**\n * Get full details for a single LOINC code, including 6-axis classification,\n * definition, related names, and cross-references.\n *\n * @example\n * ```ts\n * const detail = await autoicd.loinc.lookup(\"2345-7\");\n * console.log(detail.long_common_name);\n * console.log(detail.component, detail.system);\n * ```\n */\n async lookup(code: string): Promise<LOINCCodeDetail> {\n return this.client.get<LOINCCodeDetail>(`/api/v1/loinc/codes/${encodeURIComponent(code)}`);\n }\n\n /**\n * Search LOINC codes by description.\n *\n * @example\n * ```ts\n * const results = await autoicd.loinc.search(\"glucose\");\n * ```\n */\n async search(query: string, options?: SearchOptions): Promise<LOINCSearchResponse> {\n const params = new URLSearchParams({ q: query });\n if (options?.limit !== undefined) params.set(\"limit\", String(options.limit));\n if (options?.offset !== undefined) params.set(\"offset\", String(options.offset));\n return this.client.get<LOINCSearchResponse>(`/api/v1/loinc/codes/search?${params}`);\n }\n}\n\n// ─── Reference Sub-resource ───\n\nclass ReferenceCodes {\n constructor(private readonly client: AutoICD) {}\n\n /**\n * Look up canonical reference data for a code in any supported coding system.\n *\n * Supersedes the per-system getters (`icd10.get`, `icd11.get`, `icf.lookup`,\n * `loinc.lookup`), which remain available but emit `Deprecation` and `Sunset`\n * response headers.\n *\n * @example\n * ```ts\n * const result = await autoicd.reference.lookup(\"icd-10-cm\", \"I50.23\");\n * if (result.system === \"icd-10-cm\") {\n * console.log(result.record.long_description);\n * }\n * ```\n */\n async lookup(system: ReferenceSystem, code: string): Promise<ReferenceCodeRecord> {\n return this.client.get<ReferenceCodeRecord>(\n `/api/v1/reference/${encodeURIComponent(system)}/${encodeURIComponent(code)}`\n );\n }\n}\n\n// ─── Helpers ───\n\nfunction parseRateLimit(headers: Headers): RateLimit | null {\n const limit = headers.get(\"X-RateLimit-Limit\");\n const remaining = headers.get(\"X-RateLimit-Remaining\");\n const reset = headers.get(\"X-RateLimit-Reset\");\n\n if (!limit || !remaining || !reset) return null;\n\n return {\n limit: parseInt(limit, 10),\n remaining: parseInt(remaining, 10),\n resetAt: new Date(reset),\n };\n}\n"],"mappings":";AAEO,IAAM,eAAN,cAA2B,MAAM;AAAA,EAC7B;AAAA,EAET,YAAY,QAAgB,SAAiB;AAC3C,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,SAAS;AAAA,EAChB;AACF;AAEO,IAAM,sBAAN,cAAkC,aAAa;AAAA,EACpD,YAAY,UAAU,mBAAmB;AACvC,UAAM,KAAK,OAAO;AAClB,SAAK,OAAO;AAAA,EACd;AACF;AAEO,IAAM,iBAAN,cAA6B,aAAa;AAAA,EACtC;AAAA,EAET,YAAY,SAAiB,WAAsB;AACjD,UAAM,KAAK,OAAO;AAClB,SAAK,OAAO;AACZ,SAAK,Y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A8B,MAAM,EAAE;AAAA,EACpF;AACF;AAIA,IAAM,iBAAN,MAAqB;AAAA,EACnB,YAA6B,QAAiB;AAAjB;AAAA,EAAkB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAiB/C,MAAM,OAAO,QAAyB,MAA4C;AAChF,WAAO,KAAK,OAAO;AAAA,MACjB,qBAAqB,mBAAmB,MAAM,CAAC,IAAI,mBAAmB,IAAI,CAAC;AAAA,IAC7E;AAAA,EACF;AACF;AAIA,SAAS,eAAe,SAAoC;AAC1D,QAAM,QAAQ,QAAQ,IAAI,mBAAmB;AAC7C,QAAM,YAAY,QAAQ,IAAI,uBAAuB;AACrD,QAAM,QAAQ,QAAQ,IAAI,mBAAmB;AAE7C,MAAI,CAAC,SAAS,CAAC,aAAa,CAAC,MAAO,QAAO;AAE3C,SAAO;AAAA,IACL,OAAO,SAAS,OAAO,EAAE;AAAA,IACzB,WAAW,SAAS,WAAW,EAAE;AAAA,IACjC,SAAS,IAAI,KAAK,KAAK;AAAA,EACzB;AACF;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/errors.ts","../src/client.ts"],"sourcesContent":["import type { RateLimit } from \"./types.js\";\n\nexport class AutoICDError extends Error {\n readonly status: number;\n\n constructor(status: number, message: string) {\n super(message);\n this.name = \"AutoICDError\";\n this.status = status;\n }\n}\n\nexport class AuthenticationError extends AutoICDError {\n constructor(message = \"Invalid API key\") {\n super(401, message);\n this.name = \"AuthenticationError\";\n }\n}\n\nexport class RateLimitError extends AutoICDError {\n readonly rateLimit: RateLimit;\n\n constructor(message: string, rateLimit: RateLimit) {\n super(429, message);\n this.name = \"RateLimitError\";\n this.rateLimit = rateLimit;\n }\n}\n\nexport class NotFoundError extends AutoICDError {\n constructor(message = \"Resource not found\") {\n super(404, message);\n this.name = \"NotFoundError\";\n }\n}\n","import type {\n AutoICDOptions,\n CodeOptions,\n CodingResponse,\n SearchOptions,\n CodeSearchResponse,\n CodeDetail,\n CodeDetailFull,\n AnonymizeResponse,\n RateLimit,\n ErrorBody,\n ICD11CodeSearchResponse,\n ICD11CodeDetailFull,\n ICFCodeDetail,\n ICFSearchResponse,\n ICFCoreSetResult,\n LOINCCodeDetail,\n LOINCSearchResponse,\n LOINCCodingResponse,\n AuditRequest,\n AuditResponse,\n TranslateRequest,\n TranslateResponse,\n ReferenceSystem,\n ReferenceCodeRecord,\n SearchableReferenceSystem,\n ReferenceSearchResponse,\n} from \"./types.js\";\nimport {\n AutoICDError,\n AuthenticationError,\n RateLimitError,\n NotFoundError,\n} from \"./errors.js\";\n\nconst DEFAULT_BASE_URL = \"https://autoicdapi.com\";\nconst DEFAULT_TIMEOUT = 30_000;\n\nexport class AutoICD {\n private readonly apiKey: string;\n private readonly baseURL: string;\n private readonly timeout: number;\n private readonly _fetch: typeof globalThis.fetch;\n\n /** Rate limit info from the most recent API response. */\n lastRateLimit: RateLimit | null = null;\n\n /** Sub-resource for ICD-10 code lookup. */\n readonly icd10: ICD10Codes;\n\n /** Sub-resource for ICD-11 code lookup. */\n readonly icd11: ICD11Codes;\n\n /** Sub-resource for ICF code lookup and coding. */\n readonly icf: ICFCodes;\n\n /** Sub-resource for LOINC code lookup and coding. */\n readonly loinc: LOINCCodes;\n\n /** Unified cross-system reference lookup. */\n readonly reference: ReferenceCodes;\n\n constructor(options: AutoICDOptions) {\n if (!options.apiKey) {\n throw new Error(\"apiKey is required\");\n }\n this.apiKey = options.apiKey;\n this.baseURL = (options.baseURL ?? DEFAULT_BASE_URL).replace(/\\/+$/, \"\");\n this.timeout = options.timeout ?? DEFAULT_TIMEOUT;\n this._fetch = options.fetch ?? globalThis.fetch;\n this.icd10 = new ICD10Codes(this);\n this.icd11 = new ICD11Codes(this);\n this.icf = new ICFCodes(this);\n this.loinc = new LOINCCodes(this);\n this.reference = new ReferenceCodes(this);\n }\n\n // ─── Public Methods ───\n\n /**\n * Code clinical text to ICD-10-CM diagnoses.\n *\n * @example\n * ```ts\n * const result = await autoicd.code(\"Patient has type 2 diabetes\");\n * for (const entity of result.entities) {\n * console.log(entity.entity_text, entity.codes[0]?.code);\n * }\n * ```\n */\n async code(text: string, options?: CodeOptions): Promise<CodingResponse> {\n return this.post<CodingResponse>(\"/api/v1/code\", {\n text,\n top_k: options?.topK,\n include_negated: options?.includeNegated,\n output_system: options?.outputSystem,\n include_icf: options?.includeIcf,\n include_icd11: options?.includeIcd11,\n include_snomed: options?.includeSnomed,\n include_umls: options?.includeUmls,\n });\n }\n\n /**\n * Anonymize PHI/PII in clinical text.\n *\n * @example\n * ```ts\n * const result = await autoicd.anonymize(\"John Smith, DOB 01/15/1980, has COPD\");\n * console.log(result.anonymized_text);\n * // \"[NAME], DOB [DATE], has COPD\"\n * ```\n */\n async anonymize(text: string): Promise<AnonymizeResponse> {\n return this.post<AnonymizeResponse>(\"/api/v1/anonymize\", { text });\n }\n\n /**\n * Audit a chart for coding gaps, RADV risk, specificity, denial flags, and\n * a reconciled problem list. Every finding carries extractive evidence spans.\n *\n * @example\n * ```ts\n * const audit = await autoicd.audit({\n * text: \"68yo M, type 2 diabetes, chronic systolic heart failure on furosemide.\",\n * codes: [{ code: \"E11.9\", kind: \"icd10\" }],\n * capabilities: [\"hcc\", \"radv\", \"specificity\", \"denial\", \"problem_list\"],\n * context: { patient: { coverage: \"medicare_advantage\" } },\n * });\n * console.log(audit.totals.estimated_revenue_recovery);\n * for (const m of audit.missed) {\n * console.log(`${m.code} ${m.hcc_category} $${m.estimated_revenue}`);\n * }\n * ```\n */\n async audit(request: AuditRequest): Promise<AuditResponse> {\n return this.post<AuditResponse>(\"/api/v1/audit\", request as unknown as Record<string, unknown>);\n }\n\n /**\n * Translate a code between healthcare coding systems. Maps a source code\n * (ICD-10, ICD-11, SNOMED, UMLS, ICF) to equivalents in requested target\n * systems. Omit `to` to get every system reachable from the source.\n *\n * @example\n * ```ts\n * const result = await autoicd.translate({\n * from: { code: \"E11.9\", system: \"icd10\" },\n * });\n * console.log(result.mappings.icd11);\n * console.log(result.mappings.snomed);\n * ```\n */\n async translate(request: TranslateRequest): Promise<TranslateResponse> {\n return this.post<TranslateResponse>(\n \"/api/v1/translate\",\n request as unknown as Record<string, unknown>,\n );\n }\n\n // ─── Internal HTTP ───\n\n /** @internal */\n async get<T>(path: string): Promise<T> {\n return this.request<T>(\"GET\", path);\n }\n\n /** @internal */\n async post<T>(path: string, body: Record<string, unknown>): Promise<T> {\n // Strip undefined values so the API receives clean JSON\n const clean = Object.fromEntries(\n Object.entries(body).filter(([, v]) => v !== undefined)\n );\n return this.request<T>(\"POST\", path, clean);\n }\n\n private async request<T>(\n method: string,\n path: string,\n body?: Record<string, unknown>\n ): Promise<T> {\n const url = `${this.baseURL}${path}`;\n const controller = new AbortController();\n const timer = setTimeout(() => controller.abort(), this.timeout);\n\n try {\n const res = await this._fetch(url, {\n method,\n headers: {\n Authorization: `Bearer ${this.apiKey}`,\n \"Content-Type\": \"application/json\",\n Accept: \"application/json\",\n },\n body: body ? JSON.stringify(body) : undefined,\n signal: controller.signal,\n });\n\n // Parse rate limit headers\n this.lastRateLimit = parseRateLimit(res.headers);\n\n if (res.ok) {\n return (await res.json()) as T;\n }\n\n // Error responses\n const errorBody = (await res.json().catch(() => null)) as ErrorBody | null;\n const message = errorBody?.error ?? `HTTP ${res.status}`;\n\n if (res.status === 401) throw new AuthenticationError(message);\n if (res.status === 404) throw new NotFoundError(message);\n if (res.status === 429) {\n throw new RateLimitError(\n message,\n this.lastRateLimit ?? {\n limit: errorBody?.limit ?? 0,\n remaining: 0,\n resetAt: errorBody?.resetAt ? new Date(errorBody.resetAt) : new Date(),\n }\n );\n }\n\n throw new AutoICDError(res.status, message);\n } catch (err) {\n if (err instanceof AutoICDError) throw err;\n if (err instanceof DOMException && err.name === \"AbortError\") {\n throw new AutoICDError(0, `Request timed out after ${this.timeout}ms`);\n }\n throw err;\n } finally {\n clearTimeout(timer);\n }\n }\n}\n\n// ─── ICD-10 Codes Sub-resource ───\n\nclass ICD10Codes {\n constructor(private readonly client: AutoICD) {}\n\n /**\n * Search ICD-10 codes by description.\n *\n * @example\n * ```ts\n * const results = await autoicd.icd10.search(\"diabetes mellitus\");\n * ```\n */\n async search(query: string, options?: SearchOptions): Promise<CodeSearchResponse> {\n const params = new URLSearchParams({ q: query });\n if (options?.limit !== undefined) params.set(\"limit\", String(options.limit));\n if (options?.offset !== undefined) params.set(\"offset\", String(options.offset));\n return this.client.get<CodeSearchResponse>(`/api/v1/icd10/codes/search?${params}`);\n }\n\n /**\n * Get comprehensive details for a single ICD-10 code, including synonyms,\n * hierarchy (parent/children), chapter, and SNOMED CT / UMLS cross-references.\n *\n * @example\n * ```ts\n * const detail = await autoicd.icd10.get(\"E11.9\");\n * console.log(detail.long_description);\n * console.log(detail.synonyms.snomed); // SNOMED CT synonyms\n * console.log(detail.chapter?.title); // \"Endocrine, Nutritional and Metabolic Diseases\"\n * console.log(detail.children.length); // child codes\n * ```\n */\n async get(code: string): Promise<CodeDetailFull> {\n return this.client.get<CodeDetailFull>(`/api/v1/icd10/codes/${encodeURIComponent(code)}`);\n }\n\n}\n\n// ─── ICD-11 Codes Sub-resource ───\n\nclass ICD11Codes {\n constructor(private readonly client: AutoICD) {}\n\n /**\n * Search ICD-11 codes by description.\n *\n * @example\n * ```ts\n * const results = await autoicd.icd11.search(\"diabetes mellitus\");\n * ```\n */\n async search(query: string, options?: SearchOptions): Promise<ICD11CodeSearchResponse> {\n const params = new URLSearchParams({ q: query });\n if (options?.limit !== undefined) params.set(\"limit\", String(options.limit));\n if (options?.offset !== undefined) params.set(\"offset\", String(options.offset));\n return this.client.get<ICD11CodeSearchResponse>(`/api/v1/icd11/codes/search?${params}`);\n }\n\n /**\n * Get comprehensive details for a single ICD-11 code, including synonyms,\n * hierarchy (parent/children), chapter, and ICD-10 crosswalk mappings.\n *\n * @example\n * ```ts\n * const detail = await autoicd.icd11.get(\"5A11\");\n * console.log(detail.long_description);\n * console.log(detail.chapter?.title);\n * console.log(detail.icd10_mappings);\n * ```\n */\n async get(code: string): Promise<ICD11CodeDetailFull> {\n return this.client.get<ICD11CodeDetailFull>(`/api/v1/icd11/codes/${encodeURIComponent(code)}`);\n }\n}\n\n// ─── ICF Codes Sub-resource ───\n\nclass ICFCodes {\n constructor(private readonly client: AutoICD) {}\n\n /**\n * Get full details for a single ICF code, including definition,\n * hierarchy (parent/children), inclusions, exclusions, and index terms.\n *\n * @example\n * ```ts\n * const detail = await autoicd.icf.lookup(\"b280\");\n * console.log(detail.title);\n * console.log(detail.definition);\n * console.log(detail.children.length);\n * ```\n */\n async lookup(code: string): Promise<ICFCodeDetail> {\n return this.client.get<ICFCodeDetail>(`/api/v1/icf/codes/${encodeURIComponent(code)}`);\n }\n\n /**\n * Search ICF codes by description.\n *\n * @example\n * ```ts\n * const results = await autoicd.icf.search(\"pain\");\n * ```\n */\n async search(query: string, options?: SearchOptions): Promise<ICFSearchResponse> {\n const params = new URLSearchParams({ q: query });\n if (options?.limit !== undefined) params.set(\"limit\", String(options.limit));\n if (options?.offset !== undefined) params.set(\"offset\", String(options.offset));\n return this.client.get<ICFSearchResponse>(`/api/v1/icf/codes/search?${params}`);\n }\n\n /**\n * Get the ICF Core Set for an ICD-10 diagnosis code.\n *\n * @example\n * ```ts\n * const coreSet = await autoicd.icf.coreSet(\"M54.5\");\n * console.log(coreSet.condition_name);\n * console.log(coreSet.brief.length, \"brief codes\");\n * console.log(coreSet.comprehensive.length, \"comprehensive codes\");\n * ```\n */\n async coreSet(icd10Code: string): Promise<ICFCoreSetResult> {\n return this.client.get<ICFCoreSetResult>(`/api/v1/icf/core-set/${encodeURIComponent(icd10Code)}`);\n }\n}\n\n// ─── LOINC Codes Sub-resource ───\n\nclass LOINCCodes {\n constructor(private readonly client: AutoICD) {}\n\n /**\n * Code clinical text to LOINC codes.\n *\n * Extracts lab tests, imaging orders, and clinical observations from\n * free text and matches to LOINC codes using NER + SapBERT embeddings.\n *\n * @example\n * ```ts\n * const result = await autoicd.loinc.code(\"Order CBC, glucose, and TSH\");\n * for (const entity of result.results) {\n * console.log(entity.entity_text, entity.codes[0]?.code);\n * }\n * ```\n */\n async code(text: string, options?: { topK?: number }): Promise<LOINCCodingResponse> {\n return this.client.post<LOINCCodingResponse>(\"/api/v1/loinc/code\", {\n text,\n top_k: options?.topK,\n });\n }\n\n /**\n * Get full details for a single LOINC code, including 6-axis classification,\n * definition, related names, and cross-references.\n *\n * @example\n * ```ts\n * const detail = await autoicd.loinc.lookup(\"2345-7\");\n * console.log(detail.long_common_name);\n * console.log(detail.component, detail.system);\n * ```\n */\n async lookup(code: string): Promise<LOINCCodeDetail> {\n return this.client.get<LOINCCodeDetail>(`/api/v1/loinc/codes/${encodeURIComponent(code)}`);\n }\n\n /**\n * Search LOINC codes by description.\n *\n * @example\n * ```ts\n * const results = await autoicd.loinc.search(\"glucose\");\n * ```\n */\n async search(query: string, options?: SearchOptions): Promise<LOINCSearchResponse> {\n const params = new URLSearchParams({ q: query });\n if (options?.limit !== undefined) params.set(\"limit\", String(options.limit));\n if (options?.offset !== undefined) params.set(\"offset\", String(options.offset));\n return this.client.get<LOINCSearchResponse>(`/api/v1/loinc/codes/search?${params}`);\n }\n}\n\n// ─── Reference Sub-resource ───\n\nclass ReferenceCodes {\n constructor(private readonly client: AutoICD) {}\n\n /**\n * Look up canonical reference data for a code in any supported coding system.\n * Supports ICD-10-CM, ICD-11, ICF, LOINC, SNOMED CT, UMLS, and RxNorm.\n *\n * Supersedes the per-system getters (`icd10.get`, `icd11.get`, `icf.lookup`,\n * `loinc.lookup`), which remain available but emit `Deprecation` and `Sunset`\n * response headers.\n *\n * @example\n * ```ts\n * const result = await autoicd.reference.lookup(\"icd-10-cm\", \"I50.23\");\n * if (result.system === \"icd-10-cm\") {\n * console.log(result.record.long_description);\n * }\n *\n * const concept = await autoicd.reference.lookup(\"snomed-ct\", \"44054006\");\n * if (concept.system === \"snomed-ct\") {\n * console.log(concept.record.preferred_term);\n * }\n * ```\n */\n async lookup(system: ReferenceSystem, code: string): Promise<ReferenceCodeRecord> {\n return this.client.get<ReferenceCodeRecord>(\n `/api/v1/reference/${encodeURIComponent(system)}/${encodeURIComponent(code)}`\n );\n }\n\n /**\n * Search SNOMED CT, UMLS, or RxNorm by free-text query. JSON-backed systems\n * (ICD-10-CM, ICD-11, ICF, LOINC) keep their per-system search endpoints\n * (`autoicd.icd10.search`, `autoicd.icd11.search`, ...).\n *\n * @example\n * ```ts\n * const hits = await autoicd.reference.search(\"snomed-ct\", \"type 2 diabetes\", { limit: 5 });\n * for (const hit of hits.results) {\n * console.log(hit.code, hit.label, hit.meta);\n * }\n * ```\n */\n async search(\n system: SearchableReferenceSystem,\n query: string,\n options?: { limit?: number },\n ): Promise<ReferenceSearchResponse> {\n const params = new URLSearchParams({ q: query });\n if (options?.limit !== undefined) params.set(\"limit\", String(options.limit));\n return this.client.get<ReferenceSearchResponse>(\n `/api/v1/reference/${encodeURIComponent(system)}/search?${params}`,\n );\n }\n}\n\n// ─── Helpers ───\n\nfunction parseRateLimit(headers: Headers): RateLimit | null {\n const limit = headers.get(\"X-RateLimit-Limit\");\n const remaining = headers.get(\"X-RateLimit-Remaining\");\n const reset = headers.get(\"X-RateLimit-Reset\");\n\n if (!limit || !remaining || !reset) return null;\n\n return {\n limit: parseInt(limit, 10),\n remaining: parseInt(remaining, 10),\n resetAt: new Date(reset),\n };\n}\n"],"mappings":";AAEO,IAAM,eAAN,cAA2B,MAAM;AAAA,EAC7B;AAAA,EAET,YAAY,QAAgB,SAAiB;AAC3C,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,SAAS;AAAA,EAChB;AACF;AAEO,IAAM,sBAAN,cAAkC,aAAa;AAAA,EACpD,YAAY,UAAU,mBAAmB;AACvC,UAAM,KAAK,OAAO;AAClB,SAAK,OAAO;AAAA,EACd;AACF;AAEO,IAAM,iBAAN,cAA6B,aAAa;AAAA,EACtC;AAAA,EAET,YAAY,SAAiB,WAAsB;AACjD,UAA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-
"version": "0.
|
|
4
|
-
"description": "AI medical coding SDK — convert clinical text to ICD-10-CM and ICD-11 diagnosis codes with AI-powered NLP.
|
|
3
|
+
"version": "0.11.0",
|
|
4
|
+
"description": "AI medical coding SDK — convert clinical text to ICD-10-CM and ICD-11 diagnosis codes with AI-powered NLP. Unified reference lookup for ICD-10, ICD-11, ICF, LOINC, SNOMED CT, UMLS, and RxNorm. Chart audit (HCC gap capture, RADV, specificity, denial risk), cross-standard translate, and PHI de-identification for EHR, billing, and health-tech apps.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
@@ -61,7 +61,15 @@
|
|
|
61
61
|
"ai-icd-10",
|
|
62
62
|
"automated-diagnosis-coding",
|
|
63
63
|
"ai-medical-coder",
|
|
64
|
-
"computer-assisted-coding"
|
|
64
|
+
"computer-assisted-coding",
|
|
65
|
+
"rxnorm",
|
|
66
|
+
"loinc",
|
|
67
|
+
"icf",
|
|
68
|
+
"hcc-audit",
|
|
69
|
+
"raf",
|
|
70
|
+
"radv",
|
|
71
|
+
"chart-audit",
|
|
72
|
+
"medical-terminology"
|
|
65
73
|
],
|
|
66
74
|
"author": "AutoICD",
|
|
67
75
|
"license": "MIT",
|