autoicd-js 0.8.0 → 0.10.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 +30 -27
- package/dist/index.d.mts +46 -25
- package/dist/index.d.ts +46 -25
- package/dist/index.js +28 -17
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +28 -17
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -253,13 +253,18 @@ for (const mapping of detail.icd11_mappings ?? []) {
|
|
|
253
253
|
|
|
254
254
|
### ICF Functioning Codes
|
|
255
255
|
|
|
256
|
-
|
|
256
|
+
Look up WHO ICF categories, search the catalog, and access ICF Core Sets for 12+ conditions. To extract ICF functioning categories from clinical text, pass `includeIcf: true` to `autoicd.code()`; the response includes `icf_entities` alongside the ICD-10 results.
|
|
257
257
|
|
|
258
258
|
```typescript
|
|
259
|
-
//
|
|
260
|
-
const
|
|
261
|
-
|
|
262
|
-
|
|
259
|
+
// Extract ICF functioning categories during ICD-10 coding
|
|
260
|
+
const result = await client.code(
|
|
261
|
+
"Patient with stroke and hemiplegia",
|
|
262
|
+
{ includeIcf: true }
|
|
263
|
+
);
|
|
264
|
+
for (const entity of result.icf_entities ?? []) {
|
|
265
|
+
console.log(entity.entity_text, entity.codes[0]?.code);
|
|
266
|
+
// "hemiplegia" "b730"
|
|
267
|
+
}
|
|
263
268
|
|
|
264
269
|
// Look up an ICF code
|
|
265
270
|
const code = await client.icf.lookup("d450");
|
|
@@ -271,7 +276,7 @@ const results = await client.icf.search("mobility");
|
|
|
271
276
|
|
|
272
277
|
// Get ICF Core Set for a diagnosis
|
|
273
278
|
const coreSet = await client.icf.coreSet("E11.9");
|
|
274
|
-
console.log(coreSet.
|
|
279
|
+
console.log(coreSet.condition_name); // "Diabetes Mellitus"
|
|
275
280
|
console.log(coreSet.brief); // [{ code: "b530", title: "Weight maintenance functions", ... }]
|
|
276
281
|
```
|
|
277
282
|
|
|
@@ -299,22 +304,22 @@ The SDK can code any of the 74,000+ ICD-10-CM codes. Here are some of the most c
|
|
|
299
304
|
|
|
300
305
|
| Condition | ICD-10 Code | Description |
|
|
301
306
|
|-----------|-------------|-------------|
|
|
302
|
-
| [Hypertension](https://autoicdapi.com/
|
|
303
|
-
| [Type 2 Diabetes](https://autoicdapi.com/
|
|
304
|
-
| [Depression](https://autoicdapi.com/
|
|
305
|
-
| [Anxiety](https://autoicdapi.com/
|
|
306
|
-
| [Low Back Pain](https://autoicdapi.com/
|
|
307
|
-
| [COPD](https://autoicdapi.com/
|
|
308
|
-
| [Heart Failure](https://autoicdapi.com/
|
|
309
|
-
| [UTI](https://autoicdapi.com/
|
|
310
|
-
| [Pneumonia](https://autoicdapi.com/
|
|
311
|
-
| [Atrial Fibrillation](https://autoicdapi.com/
|
|
312
|
-
| [Obesity](https://autoicdapi.com/
|
|
313
|
-
| [GERD](https://autoicdapi.com/
|
|
314
|
-
| [Hypothyroidism](https://autoicdapi.com/
|
|
315
|
-
| [CKD](https://autoicdapi.com/
|
|
316
|
-
|
|
317
|
-
Browse all 74,000+ codes in the [ICD-10-CM Code Directory](https://autoicdapi.com/
|
|
307
|
+
| [Hypertension](https://autoicdapi.com/reference/icd-10/condition/hypertension) | [I10](https://autoicdapi.com/reference/icd-10/I10) | Essential (primary) hypertension |
|
|
308
|
+
| [Type 2 Diabetes](https://autoicdapi.com/reference/icd-10/condition/diabetes) | [E11.9](https://autoicdapi.com/reference/icd-10/E11.9) | Type 2 diabetes mellitus without complications |
|
|
309
|
+
| [Depression](https://autoicdapi.com/reference/icd-10/condition/depression) | [F32.9](https://autoicdapi.com/reference/icd-10/F32.9) | Major depressive disorder, single episode, unspecified |
|
|
310
|
+
| [Anxiety](https://autoicdapi.com/reference/icd-10/condition/anxiety) | [F41.1](https://autoicdapi.com/reference/icd-10/F41.1) | Generalized anxiety disorder |
|
|
311
|
+
| [Low Back Pain](https://autoicdapi.com/reference/icd-10/condition/back-pain) | [M54.5](https://autoicdapi.com/reference/icd-10/M54.5) | Low back pain |
|
|
312
|
+
| [COPD](https://autoicdapi.com/reference/icd-10/condition/copd) | [J44.9](https://autoicdapi.com/reference/icd-10/J44.9) | Chronic obstructive pulmonary disease, unspecified |
|
|
313
|
+
| [Heart Failure](https://autoicdapi.com/reference/icd-10/condition/heart-failure) | [I50.9](https://autoicdapi.com/reference/icd-10/I50.9) | Heart failure, unspecified |
|
|
314
|
+
| [UTI](https://autoicdapi.com/reference/icd-10/condition/urinary-tract-infection) | [N39.0](https://autoicdapi.com/reference/icd-10/N39.0) | Urinary tract infection, site not specified |
|
|
315
|
+
| [Pneumonia](https://autoicdapi.com/reference/icd-10/condition/pneumonia) | [J18.9](https://autoicdapi.com/reference/icd-10/J18.9) | Pneumonia, unspecified organism |
|
|
316
|
+
| [Atrial Fibrillation](https://autoicdapi.com/reference/icd-10/condition/atrial-fibrillation) | [I48.91](https://autoicdapi.com/reference/icd-10/I48.91) | Unspecified atrial fibrillation |
|
|
317
|
+
| [Obesity](https://autoicdapi.com/reference/icd-10/condition/obesity) | [E66.01](https://autoicdapi.com/reference/icd-10/E66.01) | Morbid (severe) obesity due to excess calories |
|
|
318
|
+
| [GERD](https://autoicdapi.com/reference/icd-10/condition/gerd) | [K21.9](https://autoicdapi.com/reference/icd-10/K21.9) | Gastro-esophageal reflux disease without esophagitis |
|
|
319
|
+
| [Hypothyroidism](https://autoicdapi.com/reference/icd-10/condition/hypothyroidism) | [E03.9](https://autoicdapi.com/reference/icd-10/E03.9) | Hypothyroidism, unspecified |
|
|
320
|
+
| [CKD](https://autoicdapi.com/reference/icd-10/condition/chronic-kidney-disease) | [N18.9](https://autoicdapi.com/reference/icd-10/N18.9) | Chronic kidney disease, unspecified |
|
|
321
|
+
|
|
322
|
+
Browse all 74,000+ codes in the [ICD-10-CM Code Directory](https://autoicdapi.com/reference/icd-10) or find codes by [condition](https://autoicdapi.com/reference/icd-10/condition).
|
|
318
323
|
|
|
319
324
|
---
|
|
320
325
|
|
|
@@ -389,7 +394,6 @@ Full REST API documentation at [autoicdapi.com/docs](https://autoicdapi.com/docs
|
|
|
389
394
|
| `autoicd.icd10.get(code)` | Get details for an ICD-10-CM code (incl. ICD-11 crosswalk) |
|
|
390
395
|
| `autoicd.icd11.search(query, options?)` | Search ICD-11 codes by description |
|
|
391
396
|
| `autoicd.icd11.get(code)` | Get details for an ICD-11 code (incl. ICD-10 crosswalk) |
|
|
392
|
-
| `autoicd.icf.code(text, options?)` | Code clinical text to ICF functioning categories |
|
|
393
397
|
| `autoicd.icf.lookup(code)` | Get details for an ICF code |
|
|
394
398
|
| `autoicd.icf.search(query, options?)` | Search ICF codes by keyword |
|
|
395
399
|
| `autoicd.icf.coreSet(icd10Code)` | Get ICF Core Set for an ICD-10 diagnosis |
|
|
@@ -415,7 +419,6 @@ import type {
|
|
|
415
419
|
ICD11CodeDetailFull,
|
|
416
420
|
ICD11CodeSearchResponse,
|
|
417
421
|
CrosswalkMapping,
|
|
418
|
-
ICFCodingResponse,
|
|
419
422
|
ICFCodeDetail,
|
|
420
423
|
ICFCodeSearchResponse,
|
|
421
424
|
ICFCoreSetResponse,
|
|
@@ -435,10 +438,10 @@ import type {
|
|
|
435
438
|
|
|
436
439
|
- [AutoICD API](https://autoicdapi.com) — Homepage and API key management
|
|
437
440
|
- [API Documentation](https://autoicdapi.com/docs) — Full REST API reference
|
|
438
|
-
- [ICD-10-CM Code Directory](https://autoicdapi.com/
|
|
439
|
-
- [ICD-11 Code Directory](https://autoicdapi.com/
|
|
441
|
+
- [ICD-10-CM Code Directory](https://autoicdapi.com/reference/icd-10) — Browse all 74,000+ diagnosis codes
|
|
442
|
+
- [ICD-11 Code Directory](https://autoicdapi.com/reference/icd-11) — Browse the WHO ICD-11 MMS hierarchy
|
|
440
443
|
- [ICD-10 ↔ ICD-11 Crosswalk](https://autoicdapi.com/icd10-to-icd11) — Map codes between revisions
|
|
441
|
-
- [ICD-10 Codes by Condition](https://autoicdapi.com/
|
|
444
|
+
- [ICD-10 Codes by Condition](https://autoicdapi.com/reference/icd-10/condition) — Find codes for common conditions
|
|
442
445
|
- [Python SDK](https://pypi.org/project/autoicd/) — `pip install autoicd`
|
|
443
446
|
- [MCP Server](https://www.npmjs.com/package/autoicd-mcp) — For Claude Desktop, Cursor, VS Code
|
|
444
447
|
- [SNOMED CT & UMLS Cross-References](https://autoicdapi.com/snomed-ct-umls) — Terminology mappings
|
package/dist/index.d.mts
CHANGED
|
@@ -299,16 +299,6 @@ interface ICFCodingEntity {
|
|
|
299
299
|
/** Ranked ICF code candidates. */
|
|
300
300
|
codes: ICFCodeResult[];
|
|
301
301
|
}
|
|
302
|
-
interface ICFCodingResponse {
|
|
303
|
-
/** The input text that was processed. */
|
|
304
|
-
text: string;
|
|
305
|
-
/** Coding provider used. */
|
|
306
|
-
provider: string;
|
|
307
|
-
/** Total number of entities in results. */
|
|
308
|
-
entity_count: number;
|
|
309
|
-
/** Coding results per entity. */
|
|
310
|
-
results: ICFCodingEntity[];
|
|
311
|
-
}
|
|
312
302
|
interface ICFSearchResponse {
|
|
313
303
|
/** The search query that was used. */
|
|
314
304
|
query: string;
|
|
@@ -602,6 +592,29 @@ interface TranslateResponse {
|
|
|
602
592
|
unsupported_targets: InteropSystem[];
|
|
603
593
|
provider: string;
|
|
604
594
|
}
|
|
595
|
+
/** Coding system slugs accepted by `client.reference.lookup`. */
|
|
596
|
+
type ReferenceSystem = "icd-10-cm" | "icd-11" | "icf" | "loinc";
|
|
597
|
+
/**
|
|
598
|
+
* Discriminated record returned by `GET /v1/reference/{system}/{code}`.
|
|
599
|
+
* `system` tags the variant; `record` carries the system-specific shape.
|
|
600
|
+
*/
|
|
601
|
+
type ReferenceCodeRecord = {
|
|
602
|
+
system: "icd-10-cm";
|
|
603
|
+
code: string;
|
|
604
|
+
record: CodeDetailFull;
|
|
605
|
+
} | {
|
|
606
|
+
system: "icd-11";
|
|
607
|
+
code: string;
|
|
608
|
+
record: ICD11CodeDetailFull;
|
|
609
|
+
} | {
|
|
610
|
+
system: "icf";
|
|
611
|
+
code: string;
|
|
612
|
+
record: ICFCodeDetail;
|
|
613
|
+
} | {
|
|
614
|
+
system: "loinc";
|
|
615
|
+
code: string;
|
|
616
|
+
record: LOINCCodeDetail;
|
|
617
|
+
};
|
|
605
618
|
|
|
606
619
|
declare class AutoICD {
|
|
607
620
|
private readonly apiKey;
|
|
@@ -618,6 +631,8 @@ declare class AutoICD {
|
|
|
618
631
|
readonly icf: ICFCodes;
|
|
619
632
|
/** Sub-resource for LOINC code lookup and coding. */
|
|
620
633
|
readonly loinc: LOINCCodes;
|
|
634
|
+
/** Unified cross-system reference lookup. */
|
|
635
|
+
readonly reference: ReferenceCodes;
|
|
621
636
|
constructor(options: AutoICDOptions);
|
|
622
637
|
/**
|
|
623
638
|
* Code clinical text to ICD-10-CM diagnoses.
|
|
@@ -738,20 +753,6 @@ declare class ICD11Codes {
|
|
|
738
753
|
declare class ICFCodes {
|
|
739
754
|
private readonly client;
|
|
740
755
|
constructor(client: AutoICD);
|
|
741
|
-
/**
|
|
742
|
-
* Code clinical text to ICF codes.
|
|
743
|
-
*
|
|
744
|
-
* @example
|
|
745
|
-
* ```ts
|
|
746
|
-
* const result = await autoicd.icf.code("Patient has difficulty walking");
|
|
747
|
-
* for (const entity of result.results) {
|
|
748
|
-
* console.log(entity.entity_text, entity.codes[0]?.code);
|
|
749
|
-
* }
|
|
750
|
-
* ```
|
|
751
|
-
*/
|
|
752
|
-
code(text: string, options?: {
|
|
753
|
-
topK?: number;
|
|
754
|
-
}): Promise<ICFCodingResponse>;
|
|
755
756
|
/**
|
|
756
757
|
* Get full details for a single ICF code, including definition,
|
|
757
758
|
* hierarchy (parent/children), inclusions, exclusions, and index terms.
|
|
@@ -829,6 +830,26 @@ declare class LOINCCodes {
|
|
|
829
830
|
*/
|
|
830
831
|
search(query: string, options?: SearchOptions): Promise<LOINCSearchResponse>;
|
|
831
832
|
}
|
|
833
|
+
declare class ReferenceCodes {
|
|
834
|
+
private readonly client;
|
|
835
|
+
constructor(client: AutoICD);
|
|
836
|
+
/**
|
|
837
|
+
* Look up canonical reference data for a code in any supported coding system.
|
|
838
|
+
*
|
|
839
|
+
* Supersedes the per-system getters (`icd10.get`, `icd11.get`, `icf.lookup`,
|
|
840
|
+
* `loinc.lookup`), which remain available but emit `Deprecation` and `Sunset`
|
|
841
|
+
* response headers.
|
|
842
|
+
*
|
|
843
|
+
* @example
|
|
844
|
+
* ```ts
|
|
845
|
+
* const result = await autoicd.reference.lookup("icd-10-cm", "I50.23");
|
|
846
|
+
* if (result.system === "icd-10-cm") {
|
|
847
|
+
* console.log(result.record.long_description);
|
|
848
|
+
* }
|
|
849
|
+
* ```
|
|
850
|
+
*/
|
|
851
|
+
lookup(system: ReferenceSystem, code: string): Promise<ReferenceCodeRecord>;
|
|
852
|
+
}
|
|
832
853
|
|
|
833
854
|
declare class AutoICDError extends Error {
|
|
834
855
|
readonly status: number;
|
|
@@ -845,4 +866,4 @@ declare class NotFoundError extends AutoICDError {
|
|
|
845
866
|
constructor(message?: string);
|
|
846
867
|
}
|
|
847
868
|
|
|
848
|
-
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
|
|
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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -299,16 +299,6 @@ interface ICFCodingEntity {
|
|
|
299
299
|
/** Ranked ICF code candidates. */
|
|
300
300
|
codes: ICFCodeResult[];
|
|
301
301
|
}
|
|
302
|
-
interface ICFCodingResponse {
|
|
303
|
-
/** The input text that was processed. */
|
|
304
|
-
text: string;
|
|
305
|
-
/** Coding provider used. */
|
|
306
|
-
provider: string;
|
|
307
|
-
/** Total number of entities in results. */
|
|
308
|
-
entity_count: number;
|
|
309
|
-
/** Coding results per entity. */
|
|
310
|
-
results: ICFCodingEntity[];
|
|
311
|
-
}
|
|
312
302
|
interface ICFSearchResponse {
|
|
313
303
|
/** The search query that was used. */
|
|
314
304
|
query: string;
|
|
@@ -602,6 +592,29 @@ interface TranslateResponse {
|
|
|
602
592
|
unsupported_targets: InteropSystem[];
|
|
603
593
|
provider: string;
|
|
604
594
|
}
|
|
595
|
+
/** Coding system slugs accepted by `client.reference.lookup`. */
|
|
596
|
+
type ReferenceSystem = "icd-10-cm" | "icd-11" | "icf" | "loinc";
|
|
597
|
+
/**
|
|
598
|
+
* Discriminated record returned by `GET /v1/reference/{system}/{code}`.
|
|
599
|
+
* `system` tags the variant; `record` carries the system-specific shape.
|
|
600
|
+
*/
|
|
601
|
+
type ReferenceCodeRecord = {
|
|
602
|
+
system: "icd-10-cm";
|
|
603
|
+
code: string;
|
|
604
|
+
record: CodeDetailFull;
|
|
605
|
+
} | {
|
|
606
|
+
system: "icd-11";
|
|
607
|
+
code: string;
|
|
608
|
+
record: ICD11CodeDetailFull;
|
|
609
|
+
} | {
|
|
610
|
+
system: "icf";
|
|
611
|
+
code: string;
|
|
612
|
+
record: ICFCodeDetail;
|
|
613
|
+
} | {
|
|
614
|
+
system: "loinc";
|
|
615
|
+
code: string;
|
|
616
|
+
record: LOINCCodeDetail;
|
|
617
|
+
};
|
|
605
618
|
|
|
606
619
|
declare class AutoICD {
|
|
607
620
|
private readonly apiKey;
|
|
@@ -618,6 +631,8 @@ declare class AutoICD {
|
|
|
618
631
|
readonly icf: ICFCodes;
|
|
619
632
|
/** Sub-resource for LOINC code lookup and coding. */
|
|
620
633
|
readonly loinc: LOINCCodes;
|
|
634
|
+
/** Unified cross-system reference lookup. */
|
|
635
|
+
readonly reference: ReferenceCodes;
|
|
621
636
|
constructor(options: AutoICDOptions);
|
|
622
637
|
/**
|
|
623
638
|
* Code clinical text to ICD-10-CM diagnoses.
|
|
@@ -738,20 +753,6 @@ declare class ICD11Codes {
|
|
|
738
753
|
declare class ICFCodes {
|
|
739
754
|
private readonly client;
|
|
740
755
|
constructor(client: AutoICD);
|
|
741
|
-
/**
|
|
742
|
-
* Code clinical text to ICF codes.
|
|
743
|
-
*
|
|
744
|
-
* @example
|
|
745
|
-
* ```ts
|
|
746
|
-
* const result = await autoicd.icf.code("Patient has difficulty walking");
|
|
747
|
-
* for (const entity of result.results) {
|
|
748
|
-
* console.log(entity.entity_text, entity.codes[0]?.code);
|
|
749
|
-
* }
|
|
750
|
-
* ```
|
|
751
|
-
*/
|
|
752
|
-
code(text: string, options?: {
|
|
753
|
-
topK?: number;
|
|
754
|
-
}): Promise<ICFCodingResponse>;
|
|
755
756
|
/**
|
|
756
757
|
* Get full details for a single ICF code, including definition,
|
|
757
758
|
* hierarchy (parent/children), inclusions, exclusions, and index terms.
|
|
@@ -829,6 +830,26 @@ declare class LOINCCodes {
|
|
|
829
830
|
*/
|
|
830
831
|
search(query: string, options?: SearchOptions): Promise<LOINCSearchResponse>;
|
|
831
832
|
}
|
|
833
|
+
declare class ReferenceCodes {
|
|
834
|
+
private readonly client;
|
|
835
|
+
constructor(client: AutoICD);
|
|
836
|
+
/**
|
|
837
|
+
* Look up canonical reference data for a code in any supported coding system.
|
|
838
|
+
*
|
|
839
|
+
* Supersedes the per-system getters (`icd10.get`, `icd11.get`, `icf.lookup`,
|
|
840
|
+
* `loinc.lookup`), which remain available but emit `Deprecation` and `Sunset`
|
|
841
|
+
* response headers.
|
|
842
|
+
*
|
|
843
|
+
* @example
|
|
844
|
+
* ```ts
|
|
845
|
+
* const result = await autoicd.reference.lookup("icd-10-cm", "I50.23");
|
|
846
|
+
* if (result.system === "icd-10-cm") {
|
|
847
|
+
* console.log(result.record.long_description);
|
|
848
|
+
* }
|
|
849
|
+
* ```
|
|
850
|
+
*/
|
|
851
|
+
lookup(system: ReferenceSystem, code: string): Promise<ReferenceCodeRecord>;
|
|
852
|
+
}
|
|
832
853
|
|
|
833
854
|
declare class AutoICDError extends Error {
|
|
834
855
|
readonly status: number;
|
|
@@ -845,4 +866,4 @@ declare class NotFoundError extends AutoICDError {
|
|
|
845
866
|
constructor(message?: string);
|
|
846
867
|
}
|
|
847
868
|
|
|
848
|
-
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
|
|
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 };
|
package/dist/index.js
CHANGED
|
@@ -76,6 +76,8 @@ var AutoICD = class {
|
|
|
76
76
|
icf;
|
|
77
77
|
/** Sub-resource for LOINC code lookup and coding. */
|
|
78
78
|
loinc;
|
|
79
|
+
/** Unified cross-system reference lookup. */
|
|
80
|
+
reference;
|
|
79
81
|
constructor(options) {
|
|
80
82
|
if (!options.apiKey) {
|
|
81
83
|
throw new Error("apiKey is required");
|
|
@@ -88,6 +90,7 @@ var AutoICD = class {
|
|
|
88
90
|
this.icd11 = new ICD11Codes(this);
|
|
89
91
|
this.icf = new ICFCodes(this);
|
|
90
92
|
this.loinc = new LOINCCodes(this);
|
|
93
|
+
this.reference = new ReferenceCodes(this);
|
|
91
94
|
}
|
|
92
95
|
// ─── Public Methods ───
|
|
93
96
|
/**
|
|
@@ -297,23 +300,6 @@ var ICFCodes = class {
|
|
|
297
300
|
constructor(client) {
|
|
298
301
|
this.client = client;
|
|
299
302
|
}
|
|
300
|
-
/**
|
|
301
|
-
* Code clinical text to ICF codes.
|
|
302
|
-
*
|
|
303
|
-
* @example
|
|
304
|
-
* ```ts
|
|
305
|
-
* const result = await autoicd.icf.code("Patient has difficulty walking");
|
|
306
|
-
* for (const entity of result.results) {
|
|
307
|
-
* console.log(entity.entity_text, entity.codes[0]?.code);
|
|
308
|
-
* }
|
|
309
|
-
* ```
|
|
310
|
-
*/
|
|
311
|
-
async code(text, options) {
|
|
312
|
-
return this.client.post("/api/v1/icf/code", {
|
|
313
|
-
text,
|
|
314
|
-
top_k: options?.topK
|
|
315
|
-
});
|
|
316
|
-
}
|
|
317
303
|
/**
|
|
318
304
|
* Get full details for a single ICF code, including definition,
|
|
319
305
|
* hierarchy (parent/children), inclusions, exclusions, and index terms.
|
|
@@ -411,6 +397,31 @@ var LOINCCodes = class {
|
|
|
411
397
|
return this.client.get(`/api/v1/loinc/codes/search?${params}`);
|
|
412
398
|
}
|
|
413
399
|
};
|
|
400
|
+
var ReferenceCodes = class {
|
|
401
|
+
constructor(client) {
|
|
402
|
+
this.client = client;
|
|
403
|
+
}
|
|
404
|
+
/**
|
|
405
|
+
* Look up canonical reference data for a code in any supported coding system.
|
|
406
|
+
*
|
|
407
|
+
* Supersedes the per-system getters (`icd10.get`, `icd11.get`, `icf.lookup`,
|
|
408
|
+
* `loinc.lookup`), which remain available but emit `Deprecation` and `Sunset`
|
|
409
|
+
* response headers.
|
|
410
|
+
*
|
|
411
|
+
* @example
|
|
412
|
+
* ```ts
|
|
413
|
+
* const result = await autoicd.reference.lookup("icd-10-cm", "I50.23");
|
|
414
|
+
* if (result.system === "icd-10-cm") {
|
|
415
|
+
* console.log(result.record.long_description);
|
|
416
|
+
* }
|
|
417
|
+
* ```
|
|
418
|
+
*/
|
|
419
|
+
async lookup(system, code) {
|
|
420
|
+
return this.client.get(
|
|
421
|
+
`/api/v1/reference/${encodeURIComponent(system)}/${encodeURIComponent(code)}`
|
|
422
|
+
);
|
|
423
|
+
}
|
|
424
|
+
};
|
|
414
425
|
function parseRateLimit(headers) {
|
|
415
426
|
const limit = headers.get("X-RateLimit-Limit");
|
|
416
427
|
const remaining = headers.get("X-RateLimit-Remaining");
|
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 ICFCodingResponse,\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} 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 ICFCodingResponse,\n ICFCodeDetail,\n ICFSearchResponse,\n ICFCoreSetResult,\n LOINCCodeDetail,\n LOINCSearchResponse,\n LOINCCodingResponse,\n AuditRequest,\n AuditResponse,\n TranslateRequest,\n TranslateResponse,\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 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 }\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 * Code clinical text to ICF codes.\n *\n * @example\n * ```ts\n * const result = await autoicd.icf.code(\"Patient has difficulty walking\");\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<ICFCodingResponse> {\n return this.client.post<ICFCodingResponse>(\"/api/v1/icf/code\", {\n text,\n top_k: options?.topK,\n });\n }\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// ─── 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,cAA4B,aAAa;AAAA,EAC9C,YAAY,UAAU,sBAAsB;AAC1C,UAAM,KAAK,OAAO;AAClB,SAAK,OAAO;AAAA,EACd;AACF;;;ACFA,IAAM,mBAAmB;AACzB,IAAM,kBAAkB;AAEjB,IAAM,UAAN,MAAc;AAAA,EACF;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA;AAAA,EAGjB,gBAAkC;AAAA;AAAA,EAGzB;AAAA;AAAA,EA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,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} 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,EACtC;AAAA,EAET,YAAY,SAAiB,WAAsB;AACjD,UAAM,KAAK,OAAO;AAClB,SAAK,OAAO;AACZ,SAAK,YAAY;AAAA,EACnB;AACF;AAEO,IAAM,gBAAN,cAA4B,aAAa;AAAA,EAC9C,YAAY,UAAU,sBAAsB;AAC1C,UAAM,KAAK,OAAO;AAClB,SAAK,OAAO;AAAA,EACd;AACF;;;ACDA,IAAM,mBAAmB;AACzB,IAAM,kBA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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":[]}
|
package/dist/index.mjs
CHANGED
|
@@ -46,6 +46,8 @@ var AutoICD = class {
|
|
|
46
46
|
icf;
|
|
47
47
|
/** Sub-resource for LOINC code lookup and coding. */
|
|
48
48
|
loinc;
|
|
49
|
+
/** Unified cross-system reference lookup. */
|
|
50
|
+
reference;
|
|
49
51
|
constructor(options) {
|
|
50
52
|
if (!options.apiKey) {
|
|
51
53
|
throw new Error("apiKey is required");
|
|
@@ -58,6 +60,7 @@ var AutoICD = class {
|
|
|
58
60
|
this.icd11 = new ICD11Codes(this);
|
|
59
61
|
this.icf = new ICFCodes(this);
|
|
60
62
|
this.loinc = new LOINCCodes(this);
|
|
63
|
+
this.reference = new ReferenceCodes(this);
|
|
61
64
|
}
|
|
62
65
|
// ─── Public Methods ───
|
|
63
66
|
/**
|
|
@@ -267,23 +270,6 @@ var ICFCodes = class {
|
|
|
267
270
|
constructor(client) {
|
|
268
271
|
this.client = client;
|
|
269
272
|
}
|
|
270
|
-
/**
|
|
271
|
-
* Code clinical text to ICF codes.
|
|
272
|
-
*
|
|
273
|
-
* @example
|
|
274
|
-
* ```ts
|
|
275
|
-
* const result = await autoicd.icf.code("Patient has difficulty walking");
|
|
276
|
-
* for (const entity of result.results) {
|
|
277
|
-
* console.log(entity.entity_text, entity.codes[0]?.code);
|
|
278
|
-
* }
|
|
279
|
-
* ```
|
|
280
|
-
*/
|
|
281
|
-
async code(text, options) {
|
|
282
|
-
return this.client.post("/api/v1/icf/code", {
|
|
283
|
-
text,
|
|
284
|
-
top_k: options?.topK
|
|
285
|
-
});
|
|
286
|
-
}
|
|
287
273
|
/**
|
|
288
274
|
* Get full details for a single ICF code, including definition,
|
|
289
275
|
* hierarchy (parent/children), inclusions, exclusions, and index terms.
|
|
@@ -381,6 +367,31 @@ var LOINCCodes = class {
|
|
|
381
367
|
return this.client.get(`/api/v1/loinc/codes/search?${params}`);
|
|
382
368
|
}
|
|
383
369
|
};
|
|
370
|
+
var ReferenceCodes = class {
|
|
371
|
+
constructor(client) {
|
|
372
|
+
this.client = client;
|
|
373
|
+
}
|
|
374
|
+
/**
|
|
375
|
+
* Look up canonical reference data for a code in any supported coding system.
|
|
376
|
+
*
|
|
377
|
+
* Supersedes the per-system getters (`icd10.get`, `icd11.get`, `icf.lookup`,
|
|
378
|
+
* `loinc.lookup`), which remain available but emit `Deprecation` and `Sunset`
|
|
379
|
+
* response headers.
|
|
380
|
+
*
|
|
381
|
+
* @example
|
|
382
|
+
* ```ts
|
|
383
|
+
* const result = await autoicd.reference.lookup("icd-10-cm", "I50.23");
|
|
384
|
+
* if (result.system === "icd-10-cm") {
|
|
385
|
+
* console.log(result.record.long_description);
|
|
386
|
+
* }
|
|
387
|
+
* ```
|
|
388
|
+
*/
|
|
389
|
+
async lookup(system, code) {
|
|
390
|
+
return this.client.get(
|
|
391
|
+
`/api/v1/reference/${encodeURIComponent(system)}/${encodeURIComponent(code)}`
|
|
392
|
+
);
|
|
393
|
+
}
|
|
394
|
+
};
|
|
384
395
|
function parseRateLimit(headers) {
|
|
385
396
|
const limit = headers.get("X-RateLimit-Limit");
|
|
386
397
|
const remaining = headers.get("X-RateLimit-Remaining");
|
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 ICFCodingResponse,\n ICFCodeDetail,\n ICFSearchResponse,\n ICFCoreSetResult,\n LOINCCodeDetail,\n LOINCSearchResponse,\n LOINCCodingResponse,\n AuditRequest,\n AuditResponse,\n TranslateRequest,\n TranslateResponse,\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 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 }\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 * Code clinical text to ICF codes.\n *\n * @example\n * ```ts\n * const result = await autoicd.icf.code(\"Patient has difficulty walking\");\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<ICFCodingResponse> {\n return this.client.post<ICFCodingResponse>(\"/api/v1/icf/code\", {\n text,\n top_k: options?.topK,\n });\n }\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// ─── 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,YAAY;AAAA,EACnB;AACF;AAEO,IAAM,gBAAN,cAA4B,aAAa;AAAA,EAC9C,YAAY,UAAU,sBAAsB;AAC1C,UAAM,KAAK,OAAO;AAClB,SAAK,OAAO;AAAA,EACd;AACF;;;ACFA,IAAM,mBAAmB;AACzB,IAAM,kBAAkB;AAEjB,IAAM,UAAN,MAAc;AAAA,EACF;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA;AAAA,EAGjB,gBAAkC;AAAA;AAAA,EAGzB;AAAA;AAAA,EAGA;AAAA;AAAA,EAGA;AAAA;A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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} 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,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,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":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "autoicd-js",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"description": "AI medical coding SDK — convert clinical text to ICD-10-CM and ICD-11 diagnosis codes with AI-powered NLP. Automated ICD-10 coding, PHI de-identification, code search, and ICD-10/ICD-11 crosswalk for EHR, billing, and health-tech apps.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|