autoicd-js 0.5.0 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,314 @@
1
+ interface AutoICDOptions {
2
+ /** API key (starts with `sk_`). */
3
+ apiKey: string;
4
+ /** Base URL. Defaults to `https://autoicdapi.com`. */
5
+ baseURL?: string;
6
+ /** Default timeout in milliseconds. Defaults to 30_000. */
7
+ timeout?: number;
8
+ /** Custom fetch implementation (for testing or non-standard runtimes). */
9
+ fetch?: typeof globalThis.fetch;
10
+ }
11
+ interface CodeOptions {
12
+ /** Number of top ICD-10 candidates per entity (1-25). Defaults to 5. */
13
+ topK?: number;
14
+ /** Include negated entities in results. Defaults to true. */
15
+ includeNegated?: boolean;
16
+ /** Output coding system: `"icd10"` (default) or `"icd11"`. */
17
+ outputSystem?: "icd10" | "icd11";
18
+ }
19
+ interface CodeMatch {
20
+ /** ICD-10-CM code (e.g., `"E11.21"`). */
21
+ code: string;
22
+ /** Official code description. */
23
+ description: string;
24
+ /** Cosine similarity score (0-1). */
25
+ similarity: number;
26
+ /** `"high"` if above high-confidence threshold, else `"moderate"`. */
27
+ confidence: "high" | "moderate";
28
+ /** The index term that produced this match. */
29
+ matched_term: string;
30
+ }
31
+ interface CodingEntity {
32
+ /** Entity text as extracted from the input. */
33
+ entity_text: string;
34
+ /** Character offset start in input text. */
35
+ entity_start: number;
36
+ /** Character offset end in input text. */
37
+ entity_end: number;
38
+ /** Whether this entity was negated in context. */
39
+ negated: boolean;
40
+ /** Entity refers to a past/resolved condition. */
41
+ historical: boolean;
42
+ /** Entity refers to a family member's condition. */
43
+ family_history: boolean;
44
+ /** Entity is hedged or uncertain. */
45
+ uncertain: boolean;
46
+ /** Severity modifier if detected (e.g., `"severe"`). */
47
+ severity: string | null;
48
+ /** Ranked ICD-10 code candidates. */
49
+ codes: CodeMatch[];
50
+ /** Source entity texts if this result was created by merging consecutive entities. */
51
+ merged_from?: string[] | null;
52
+ /** Original text before spell correction (null if no correction). */
53
+ corrected_from?: string | null;
54
+ }
55
+ interface CodingResponse {
56
+ /** The input text that was processed. */
57
+ text: string;
58
+ /** Coding provider used. */
59
+ provider: string;
60
+ /** Total number of entities in results. */
61
+ entity_count: number;
62
+ /** Coding results per entity, sorted by position in text. */
63
+ entities: CodingEntity[];
64
+ }
65
+ interface SearchOptions {
66
+ /** Maximum number of results (1-100). Defaults to 20. */
67
+ limit?: number;
68
+ /** Number of results to skip (for pagination). Defaults to 0. */
69
+ offset?: number;
70
+ }
71
+ interface CodeDetail {
72
+ /** ICD-10-CM code. */
73
+ code: string;
74
+ /** Abbreviated description. */
75
+ short_description: string;
76
+ /** Full official description. */
77
+ long_description: string;
78
+ /** Whether this is a billable (leaf) code. */
79
+ is_billable: boolean;
80
+ }
81
+ interface ChapterInfo {
82
+ /** Chapter number (1-22). */
83
+ number: number;
84
+ /** Code range (e.g., `"E00-E89"`). */
85
+ range: string;
86
+ /** Chapter title. */
87
+ title: string;
88
+ }
89
+ interface CodeDetailFull extends CodeDetail {
90
+ /** Synonyms grouped by source: `"snomed"`, `"umls"`, `"icd10_augmented"`. */
91
+ synonyms: Record<string, string[]>;
92
+ /** Cross-reference IDs grouped by source: `"snomed"` (SNOMED CT concept IDs), `"umls"` (UMLS CUIs). */
93
+ cross_references: Record<string, string[]>;
94
+ /** Parent code in the ICD-10 hierarchy, or `null` for top-level categories. */
95
+ parent: CodeDetail | null;
96
+ /** Direct child codes in the ICD-10 hierarchy. */
97
+ children: CodeDetail[];
98
+ /** ICD-10-CM chapter this code belongs to. */
99
+ chapter: ChapterInfo | null;
100
+ /** Code block range (e.g., `"E08-E13"`). */
101
+ block: string | null;
102
+ /** ICD-11 crosswalk mappings (present when ICD-11 data is available). */
103
+ icd11_mappings?: CrosswalkMapping[];
104
+ }
105
+ interface CodeSearchResponse {
106
+ /** The search query that was used. */
107
+ query: string;
108
+ /** Number of results returned. */
109
+ count: number;
110
+ /** Matching ICD-10 codes. */
111
+ codes: CodeDetail[];
112
+ }
113
+ interface PIIEntity {
114
+ /** Original PII text. */
115
+ text: string;
116
+ /** Character offset start. */
117
+ start: number;
118
+ /** Character offset end. */
119
+ end: number;
120
+ /** PII category (NAME, DATE, SSN, PHONE, EMAIL, ADDRESS, MRN, AGE). */
121
+ label: string;
122
+ /** Replacement token (e.g., `"[NAME]"`). */
123
+ replacement: string;
124
+ }
125
+ interface AnonymizeResponse {
126
+ /** The input text that was processed. */
127
+ original_text: string;
128
+ /** Text with PII replaced by type labels. */
129
+ anonymized_text: string;
130
+ /** Number of PII entities detected. */
131
+ pii_count: number;
132
+ /** Detected PII spans with original offsets. */
133
+ pii_entities: PIIEntity[];
134
+ }
135
+ interface RateLimit {
136
+ /** Total requests allowed in the current period. */
137
+ limit: number;
138
+ /** Requests remaining. */
139
+ remaining: number;
140
+ /** UTC timestamp when the limit resets. */
141
+ resetAt: Date;
142
+ }
143
+ interface ICD11CodeDetail {
144
+ /** ICD-11 code (e.g., `"5A11"`). */
145
+ code: string;
146
+ /** Abbreviated description. */
147
+ short_description: string;
148
+ /** Full official description. */
149
+ long_description: string;
150
+ /** ICD-11 Foundation URI, or `null` if unavailable. */
151
+ foundation_uri: string | null;
152
+ }
153
+ interface ICD11ChapterInfo {
154
+ /** Chapter number. */
155
+ number: number;
156
+ /** Chapter title. */
157
+ title: string;
158
+ }
159
+ interface CrosswalkMapping {
160
+ /** Mapped code (ICD-10 or ICD-11). */
161
+ code: string;
162
+ /** Code description. */
163
+ description: string;
164
+ /** Mapping relationship: `"equivalent"`, `"narrower"`, `"broader"`, or `"approximate"`. */
165
+ mapping_type: string;
166
+ /** Target coding system: `"icd10"` or `"icd11"`. */
167
+ system: string;
168
+ }
169
+ interface ICD11CodeDetailFull extends ICD11CodeDetail {
170
+ /** Synonyms grouped by source. */
171
+ synonyms: Record<string, string[]>;
172
+ /** Cross-reference IDs grouped by source. */
173
+ cross_references: Record<string, string[]>;
174
+ /** Parent code in the ICD-11 hierarchy, or `null` for top-level categories. */
175
+ parent: ICD11CodeDetail | null;
176
+ /** Direct child codes in the ICD-11 hierarchy. */
177
+ children: ICD11CodeDetail[];
178
+ /** ICD-11 chapter this code belongs to. */
179
+ chapter: ICD11ChapterInfo | null;
180
+ /** Block within the chapter. */
181
+ block: string | null;
182
+ /** ICD-10 crosswalk mappings for this ICD-11 code. */
183
+ icd10_mappings: CrosswalkMapping[];
184
+ }
185
+ interface ICD11CodeSearchResult {
186
+ /** ICD-11 code. */
187
+ code: string;
188
+ /** Abbreviated description. */
189
+ short_description: string;
190
+ /** Full official description. */
191
+ long_description: string;
192
+ /** ICD-11 Foundation URI, or `null` if unavailable. */
193
+ foundation_uri: string | null;
194
+ }
195
+ interface ICD11CodeSearchResponse {
196
+ /** The search query that was used. */
197
+ query: string;
198
+ /** Number of results returned. */
199
+ count: number;
200
+ /** Matching ICD-11 codes. */
201
+ codes: ICD11CodeSearchResult[];
202
+ }
203
+
204
+ declare class AutoICD {
205
+ private readonly apiKey;
206
+ private readonly baseURL;
207
+ private readonly timeout;
208
+ private readonly _fetch;
209
+ /** Rate limit info from the most recent API response. */
210
+ lastRateLimit: RateLimit | null;
211
+ /** Sub-resource for ICD-10 code lookup. */
212
+ readonly codes: Codes;
213
+ /** Sub-resource for ICD-11 code lookup. */
214
+ readonly icd11: ICD11Codes;
215
+ constructor(options: AutoICDOptions);
216
+ /**
217
+ * Code clinical text to ICD-10-CM diagnoses.
218
+ *
219
+ * @example
220
+ * ```ts
221
+ * const result = await autoicd.code("Patient has type 2 diabetes");
222
+ * for (const entity of result.entities) {
223
+ * console.log(entity.entity_text, entity.codes[0]?.code);
224
+ * }
225
+ * ```
226
+ */
227
+ code(text: string, options?: CodeOptions): Promise<CodingResponse>;
228
+ /**
229
+ * Anonymize PHI/PII in clinical text.
230
+ *
231
+ * @example
232
+ * ```ts
233
+ * const result = await autoicd.anonymize("John Smith, DOB 01/15/1980, has COPD");
234
+ * console.log(result.anonymized_text);
235
+ * // "[NAME], DOB [DATE], has COPD"
236
+ * ```
237
+ */
238
+ anonymize(text: string): Promise<AnonymizeResponse>;
239
+ /** @internal */
240
+ get<T>(path: string): Promise<T>;
241
+ /** @internal */
242
+ post<T>(path: string, body: Record<string, unknown>): Promise<T>;
243
+ private request;
244
+ }
245
+ declare class Codes {
246
+ private readonly client;
247
+ constructor(client: AutoICD);
248
+ /**
249
+ * Search ICD-10 codes by description.
250
+ *
251
+ * @example
252
+ * ```ts
253
+ * const results = await autoicd.codes.search("diabetes mellitus");
254
+ * ```
255
+ */
256
+ search(query: string, options?: SearchOptions): Promise<CodeSearchResponse>;
257
+ /**
258
+ * Get comprehensive details for a single ICD-10 code, including synonyms,
259
+ * hierarchy (parent/children), chapter, and SNOMED CT / UMLS cross-references.
260
+ *
261
+ * @example
262
+ * ```ts
263
+ * const detail = await autoicd.codes.get("E11.9");
264
+ * console.log(detail.long_description);
265
+ * console.log(detail.synonyms.snomed); // SNOMED CT synonyms
266
+ * console.log(detail.chapter?.title); // "Endocrine, Nutritional and Metabolic Diseases"
267
+ * console.log(detail.children.length); // child codes
268
+ * ```
269
+ */
270
+ get(code: string): Promise<CodeDetailFull>;
271
+ }
272
+ declare class ICD11Codes {
273
+ private readonly client;
274
+ constructor(client: AutoICD);
275
+ /**
276
+ * Search ICD-11 codes by description.
277
+ *
278
+ * @example
279
+ * ```ts
280
+ * const results = await autoicd.icd11.search("diabetes mellitus");
281
+ * ```
282
+ */
283
+ search(query: string, options?: SearchOptions): Promise<ICD11CodeSearchResponse>;
284
+ /**
285
+ * Get comprehensive details for a single ICD-11 code, including synonyms,
286
+ * hierarchy (parent/children), chapter, and ICD-10 crosswalk mappings.
287
+ *
288
+ * @example
289
+ * ```ts
290
+ * const detail = await autoicd.icd11.get("5A11");
291
+ * console.log(detail.long_description);
292
+ * console.log(detail.chapter?.title);
293
+ * console.log(detail.icd10_mappings);
294
+ * ```
295
+ */
296
+ get(code: string): Promise<ICD11CodeDetailFull>;
297
+ }
298
+
299
+ declare class AutoICDError extends Error {
300
+ readonly status: number;
301
+ constructor(status: number, message: string);
302
+ }
303
+ declare class AuthenticationError extends AutoICDError {
304
+ constructor(message?: string);
305
+ }
306
+ declare class RateLimitError extends AutoICDError {
307
+ readonly rateLimit: RateLimit;
308
+ constructor(message: string, rateLimit: RateLimit);
309
+ }
310
+ declare class NotFoundError extends AutoICDError {
311
+ constructor(message?: string);
312
+ }
313
+
314
+ export { type AnonymizeResponse, AuthenticationError, AutoICD, AutoICDError, type AutoICDOptions, type ChapterInfo, type CodeDetail, type CodeDetailFull, type CodeMatch, type CodeOptions, type CodeSearchResponse, type CodingEntity, type CodingResponse, type CrosswalkMapping, type ICD11ChapterInfo, type ICD11CodeDetail, type ICD11CodeDetailFull, type ICD11CodeSearchResponse, type ICD11CodeSearchResult, NotFoundError, type PIIEntity, type RateLimit, RateLimitError, type SearchOptions };
@@ -0,0 +1,314 @@
1
+ interface AutoICDOptions {
2
+ /** API key (starts with `sk_`). */
3
+ apiKey: string;
4
+ /** Base URL. Defaults to `https://autoicdapi.com`. */
5
+ baseURL?: string;
6
+ /** Default timeout in milliseconds. Defaults to 30_000. */
7
+ timeout?: number;
8
+ /** Custom fetch implementation (for testing or non-standard runtimes). */
9
+ fetch?: typeof globalThis.fetch;
10
+ }
11
+ interface CodeOptions {
12
+ /** Number of top ICD-10 candidates per entity (1-25). Defaults to 5. */
13
+ topK?: number;
14
+ /** Include negated entities in results. Defaults to true. */
15
+ includeNegated?: boolean;
16
+ /** Output coding system: `"icd10"` (default) or `"icd11"`. */
17
+ outputSystem?: "icd10" | "icd11";
18
+ }
19
+ interface CodeMatch {
20
+ /** ICD-10-CM code (e.g., `"E11.21"`). */
21
+ code: string;
22
+ /** Official code description. */
23
+ description: string;
24
+ /** Cosine similarity score (0-1). */
25
+ similarity: number;
26
+ /** `"high"` if above high-confidence threshold, else `"moderate"`. */
27
+ confidence: "high" | "moderate";
28
+ /** The index term that produced this match. */
29
+ matched_term: string;
30
+ }
31
+ interface CodingEntity {
32
+ /** Entity text as extracted from the input. */
33
+ entity_text: string;
34
+ /** Character offset start in input text. */
35
+ entity_start: number;
36
+ /** Character offset end in input text. */
37
+ entity_end: number;
38
+ /** Whether this entity was negated in context. */
39
+ negated: boolean;
40
+ /** Entity refers to a past/resolved condition. */
41
+ historical: boolean;
42
+ /** Entity refers to a family member's condition. */
43
+ family_history: boolean;
44
+ /** Entity is hedged or uncertain. */
45
+ uncertain: boolean;
46
+ /** Severity modifier if detected (e.g., `"severe"`). */
47
+ severity: string | null;
48
+ /** Ranked ICD-10 code candidates. */
49
+ codes: CodeMatch[];
50
+ /** Source entity texts if this result was created by merging consecutive entities. */
51
+ merged_from?: string[] | null;
52
+ /** Original text before spell correction (null if no correction). */
53
+ corrected_from?: string | null;
54
+ }
55
+ interface CodingResponse {
56
+ /** The input text that was processed. */
57
+ text: string;
58
+ /** Coding provider used. */
59
+ provider: string;
60
+ /** Total number of entities in results. */
61
+ entity_count: number;
62
+ /** Coding results per entity, sorted by position in text. */
63
+ entities: CodingEntity[];
64
+ }
65
+ interface SearchOptions {
66
+ /** Maximum number of results (1-100). Defaults to 20. */
67
+ limit?: number;
68
+ /** Number of results to skip (for pagination). Defaults to 0. */
69
+ offset?: number;
70
+ }
71
+ interface CodeDetail {
72
+ /** ICD-10-CM code. */
73
+ code: string;
74
+ /** Abbreviated description. */
75
+ short_description: string;
76
+ /** Full official description. */
77
+ long_description: string;
78
+ /** Whether this is a billable (leaf) code. */
79
+ is_billable: boolean;
80
+ }
81
+ interface ChapterInfo {
82
+ /** Chapter number (1-22). */
83
+ number: number;
84
+ /** Code range (e.g., `"E00-E89"`). */
85
+ range: string;
86
+ /** Chapter title. */
87
+ title: string;
88
+ }
89
+ interface CodeDetailFull extends CodeDetail {
90
+ /** Synonyms grouped by source: `"snomed"`, `"umls"`, `"icd10_augmented"`. */
91
+ synonyms: Record<string, string[]>;
92
+ /** Cross-reference IDs grouped by source: `"snomed"` (SNOMED CT concept IDs), `"umls"` (UMLS CUIs). */
93
+ cross_references: Record<string, string[]>;
94
+ /** Parent code in the ICD-10 hierarchy, or `null` for top-level categories. */
95
+ parent: CodeDetail | null;
96
+ /** Direct child codes in the ICD-10 hierarchy. */
97
+ children: CodeDetail[];
98
+ /** ICD-10-CM chapter this code belongs to. */
99
+ chapter: ChapterInfo | null;
100
+ /** Code block range (e.g., `"E08-E13"`). */
101
+ block: string | null;
102
+ /** ICD-11 crosswalk mappings (present when ICD-11 data is available). */
103
+ icd11_mappings?: CrosswalkMapping[];
104
+ }
105
+ interface CodeSearchResponse {
106
+ /** The search query that was used. */
107
+ query: string;
108
+ /** Number of results returned. */
109
+ count: number;
110
+ /** Matching ICD-10 codes. */
111
+ codes: CodeDetail[];
112
+ }
113
+ interface PIIEntity {
114
+ /** Original PII text. */
115
+ text: string;
116
+ /** Character offset start. */
117
+ start: number;
118
+ /** Character offset end. */
119
+ end: number;
120
+ /** PII category (NAME, DATE, SSN, PHONE, EMAIL, ADDRESS, MRN, AGE). */
121
+ label: string;
122
+ /** Replacement token (e.g., `"[NAME]"`). */
123
+ replacement: string;
124
+ }
125
+ interface AnonymizeResponse {
126
+ /** The input text that was processed. */
127
+ original_text: string;
128
+ /** Text with PII replaced by type labels. */
129
+ anonymized_text: string;
130
+ /** Number of PII entities detected. */
131
+ pii_count: number;
132
+ /** Detected PII spans with original offsets. */
133
+ pii_entities: PIIEntity[];
134
+ }
135
+ interface RateLimit {
136
+ /** Total requests allowed in the current period. */
137
+ limit: number;
138
+ /** Requests remaining. */
139
+ remaining: number;
140
+ /** UTC timestamp when the limit resets. */
141
+ resetAt: Date;
142
+ }
143
+ interface ICD11CodeDetail {
144
+ /** ICD-11 code (e.g., `"5A11"`). */
145
+ code: string;
146
+ /** Abbreviated description. */
147
+ short_description: string;
148
+ /** Full official description. */
149
+ long_description: string;
150
+ /** ICD-11 Foundation URI, or `null` if unavailable. */
151
+ foundation_uri: string | null;
152
+ }
153
+ interface ICD11ChapterInfo {
154
+ /** Chapter number. */
155
+ number: number;
156
+ /** Chapter title. */
157
+ title: string;
158
+ }
159
+ interface CrosswalkMapping {
160
+ /** Mapped code (ICD-10 or ICD-11). */
161
+ code: string;
162
+ /** Code description. */
163
+ description: string;
164
+ /** Mapping relationship: `"equivalent"`, `"narrower"`, `"broader"`, or `"approximate"`. */
165
+ mapping_type: string;
166
+ /** Target coding system: `"icd10"` or `"icd11"`. */
167
+ system: string;
168
+ }
169
+ interface ICD11CodeDetailFull extends ICD11CodeDetail {
170
+ /** Synonyms grouped by source. */
171
+ synonyms: Record<string, string[]>;
172
+ /** Cross-reference IDs grouped by source. */
173
+ cross_references: Record<string, string[]>;
174
+ /** Parent code in the ICD-11 hierarchy, or `null` for top-level categories. */
175
+ parent: ICD11CodeDetail | null;
176
+ /** Direct child codes in the ICD-11 hierarchy. */
177
+ children: ICD11CodeDetail[];
178
+ /** ICD-11 chapter this code belongs to. */
179
+ chapter: ICD11ChapterInfo | null;
180
+ /** Block within the chapter. */
181
+ block: string | null;
182
+ /** ICD-10 crosswalk mappings for this ICD-11 code. */
183
+ icd10_mappings: CrosswalkMapping[];
184
+ }
185
+ interface ICD11CodeSearchResult {
186
+ /** ICD-11 code. */
187
+ code: string;
188
+ /** Abbreviated description. */
189
+ short_description: string;
190
+ /** Full official description. */
191
+ long_description: string;
192
+ /** ICD-11 Foundation URI, or `null` if unavailable. */
193
+ foundation_uri: string | null;
194
+ }
195
+ interface ICD11CodeSearchResponse {
196
+ /** The search query that was used. */
197
+ query: string;
198
+ /** Number of results returned. */
199
+ count: number;
200
+ /** Matching ICD-11 codes. */
201
+ codes: ICD11CodeSearchResult[];
202
+ }
203
+
204
+ declare class AutoICD {
205
+ private readonly apiKey;
206
+ private readonly baseURL;
207
+ private readonly timeout;
208
+ private readonly _fetch;
209
+ /** Rate limit info from the most recent API response. */
210
+ lastRateLimit: RateLimit | null;
211
+ /** Sub-resource for ICD-10 code lookup. */
212
+ readonly codes: Codes;
213
+ /** Sub-resource for ICD-11 code lookup. */
214
+ readonly icd11: ICD11Codes;
215
+ constructor(options: AutoICDOptions);
216
+ /**
217
+ * Code clinical text to ICD-10-CM diagnoses.
218
+ *
219
+ * @example
220
+ * ```ts
221
+ * const result = await autoicd.code("Patient has type 2 diabetes");
222
+ * for (const entity of result.entities) {
223
+ * console.log(entity.entity_text, entity.codes[0]?.code);
224
+ * }
225
+ * ```
226
+ */
227
+ code(text: string, options?: CodeOptions): Promise<CodingResponse>;
228
+ /**
229
+ * Anonymize PHI/PII in clinical text.
230
+ *
231
+ * @example
232
+ * ```ts
233
+ * const result = await autoicd.anonymize("John Smith, DOB 01/15/1980, has COPD");
234
+ * console.log(result.anonymized_text);
235
+ * // "[NAME], DOB [DATE], has COPD"
236
+ * ```
237
+ */
238
+ anonymize(text: string): Promise<AnonymizeResponse>;
239
+ /** @internal */
240
+ get<T>(path: string): Promise<T>;
241
+ /** @internal */
242
+ post<T>(path: string, body: Record<string, unknown>): Promise<T>;
243
+ private request;
244
+ }
245
+ declare class Codes {
246
+ private readonly client;
247
+ constructor(client: AutoICD);
248
+ /**
249
+ * Search ICD-10 codes by description.
250
+ *
251
+ * @example
252
+ * ```ts
253
+ * const results = await autoicd.codes.search("diabetes mellitus");
254
+ * ```
255
+ */
256
+ search(query: string, options?: SearchOptions): Promise<CodeSearchResponse>;
257
+ /**
258
+ * Get comprehensive details for a single ICD-10 code, including synonyms,
259
+ * hierarchy (parent/children), chapter, and SNOMED CT / UMLS cross-references.
260
+ *
261
+ * @example
262
+ * ```ts
263
+ * const detail = await autoicd.codes.get("E11.9");
264
+ * console.log(detail.long_description);
265
+ * console.log(detail.synonyms.snomed); // SNOMED CT synonyms
266
+ * console.log(detail.chapter?.title); // "Endocrine, Nutritional and Metabolic Diseases"
267
+ * console.log(detail.children.length); // child codes
268
+ * ```
269
+ */
270
+ get(code: string): Promise<CodeDetailFull>;
271
+ }
272
+ declare class ICD11Codes {
273
+ private readonly client;
274
+ constructor(client: AutoICD);
275
+ /**
276
+ * Search ICD-11 codes by description.
277
+ *
278
+ * @example
279
+ * ```ts
280
+ * const results = await autoicd.icd11.search("diabetes mellitus");
281
+ * ```
282
+ */
283
+ search(query: string, options?: SearchOptions): Promise<ICD11CodeSearchResponse>;
284
+ /**
285
+ * Get comprehensive details for a single ICD-11 code, including synonyms,
286
+ * hierarchy (parent/children), chapter, and ICD-10 crosswalk mappings.
287
+ *
288
+ * @example
289
+ * ```ts
290
+ * const detail = await autoicd.icd11.get("5A11");
291
+ * console.log(detail.long_description);
292
+ * console.log(detail.chapter?.title);
293
+ * console.log(detail.icd10_mappings);
294
+ * ```
295
+ */
296
+ get(code: string): Promise<ICD11CodeDetailFull>;
297
+ }
298
+
299
+ declare class AutoICDError extends Error {
300
+ readonly status: number;
301
+ constructor(status: number, message: string);
302
+ }
303
+ declare class AuthenticationError extends AutoICDError {
304
+ constructor(message?: string);
305
+ }
306
+ declare class RateLimitError extends AutoICDError {
307
+ readonly rateLimit: RateLimit;
308
+ constructor(message: string, rateLimit: RateLimit);
309
+ }
310
+ declare class NotFoundError extends AutoICDError {
311
+ constructor(message?: string);
312
+ }
313
+
314
+ export { type AnonymizeResponse, AuthenticationError, AutoICD, AutoICDError, type AutoICDOptions, type ChapterInfo, type CodeDetail, type CodeDetailFull, type CodeMatch, type CodeOptions, type CodeSearchResponse, type CodingEntity, type CodingResponse, type CrosswalkMapping, type ICD11ChapterInfo, type ICD11CodeDetail, type ICD11CodeDetailFull, type ICD11CodeSearchResponse, type ICD11CodeSearchResult, NotFoundError, type PIIEntity, type RateLimit, RateLimitError, type SearchOptions };
package/dist/index.js ADDED
@@ -0,0 +1,264 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ AuthenticationError: () => AuthenticationError,
24
+ AutoICD: () => AutoICD,
25
+ AutoICDError: () => AutoICDError,
26
+ NotFoundError: () => NotFoundError,
27
+ RateLimitError: () => RateLimitError
28
+ });
29
+ module.exports = __toCommonJS(index_exports);
30
+
31
+ // src/errors.ts
32
+ var AutoICDError = class extends Error {
33
+ status;
34
+ constructor(status, message) {
35
+ super(message);
36
+ this.name = "AutoICDError";
37
+ this.status = status;
38
+ }
39
+ };
40
+ var AuthenticationError = class extends AutoICDError {
41
+ constructor(message = "Invalid API key") {
42
+ super(401, message);
43
+ this.name = "AuthenticationError";
44
+ }
45
+ };
46
+ var RateLimitError = class extends AutoICDError {
47
+ rateLimit;
48
+ constructor(message, rateLimit) {
49
+ super(429, message);
50
+ this.name = "RateLimitError";
51
+ this.rateLimit = rateLimit;
52
+ }
53
+ };
54
+ var NotFoundError = class extends AutoICDError {
55
+ constructor(message = "Resource not found") {
56
+ super(404, message);
57
+ this.name = "NotFoundError";
58
+ }
59
+ };
60
+
61
+ // src/client.ts
62
+ var DEFAULT_BASE_URL = "https://autoicdapi.com";
63
+ var DEFAULT_TIMEOUT = 3e4;
64
+ var AutoICD = class {
65
+ apiKey;
66
+ baseURL;
67
+ timeout;
68
+ _fetch;
69
+ /** Rate limit info from the most recent API response. */
70
+ lastRateLimit = null;
71
+ /** Sub-resource for ICD-10 code lookup. */
72
+ codes;
73
+ /** Sub-resource for ICD-11 code lookup. */
74
+ icd11;
75
+ constructor(options) {
76
+ if (!options.apiKey) {
77
+ throw new Error("apiKey is required");
78
+ }
79
+ this.apiKey = options.apiKey;
80
+ this.baseURL = (options.baseURL ?? DEFAULT_BASE_URL).replace(/\/+$/, "");
81
+ this.timeout = options.timeout ?? DEFAULT_TIMEOUT;
82
+ this._fetch = options.fetch ?? globalThis.fetch;
83
+ this.codes = new Codes(this);
84
+ this.icd11 = new ICD11Codes(this);
85
+ }
86
+ // ─── Public Methods ───
87
+ /**
88
+ * Code clinical text to ICD-10-CM diagnoses.
89
+ *
90
+ * @example
91
+ * ```ts
92
+ * const result = await autoicd.code("Patient has type 2 diabetes");
93
+ * for (const entity of result.entities) {
94
+ * console.log(entity.entity_text, entity.codes[0]?.code);
95
+ * }
96
+ * ```
97
+ */
98
+ async code(text, options) {
99
+ return this.post("/api/v1/code", {
100
+ text,
101
+ top_k: options?.topK,
102
+ include_negated: options?.includeNegated,
103
+ output_system: options?.outputSystem
104
+ });
105
+ }
106
+ /**
107
+ * Anonymize PHI/PII in clinical text.
108
+ *
109
+ * @example
110
+ * ```ts
111
+ * const result = await autoicd.anonymize("John Smith, DOB 01/15/1980, has COPD");
112
+ * console.log(result.anonymized_text);
113
+ * // "[NAME], DOB [DATE], has COPD"
114
+ * ```
115
+ */
116
+ async anonymize(text) {
117
+ return this.post("/api/v1/anonymize", { text });
118
+ }
119
+ // ─── Internal HTTP ───
120
+ /** @internal */
121
+ async get(path) {
122
+ return this.request("GET", path);
123
+ }
124
+ /** @internal */
125
+ async post(path, body) {
126
+ const clean = Object.fromEntries(
127
+ Object.entries(body).filter(([, v]) => v !== void 0)
128
+ );
129
+ return this.request("POST", path, clean);
130
+ }
131
+ async request(method, path, body) {
132
+ const url = `${this.baseURL}${path}`;
133
+ const controller = new AbortController();
134
+ const timer = setTimeout(() => controller.abort(), this.timeout);
135
+ try {
136
+ const res = await this._fetch(url, {
137
+ method,
138
+ headers: {
139
+ Authorization: `Bearer ${this.apiKey}`,
140
+ "Content-Type": "application/json",
141
+ Accept: "application/json"
142
+ },
143
+ body: body ? JSON.stringify(body) : void 0,
144
+ signal: controller.signal
145
+ });
146
+ this.lastRateLimit = parseRateLimit(res.headers);
147
+ if (res.ok) {
148
+ return await res.json();
149
+ }
150
+ const errorBody = await res.json().catch(() => null);
151
+ const message = errorBody?.error ?? `HTTP ${res.status}`;
152
+ if (res.status === 401) throw new AuthenticationError(message);
153
+ if (res.status === 404) throw new NotFoundError(message);
154
+ if (res.status === 429) {
155
+ throw new RateLimitError(
156
+ message,
157
+ this.lastRateLimit ?? {
158
+ limit: errorBody?.limit ?? 0,
159
+ remaining: 0,
160
+ resetAt: errorBody?.resetAt ? new Date(errorBody.resetAt) : /* @__PURE__ */ new Date()
161
+ }
162
+ );
163
+ }
164
+ throw new AutoICDError(res.status, message);
165
+ } catch (err) {
166
+ if (err instanceof AutoICDError) throw err;
167
+ if (err instanceof DOMException && err.name === "AbortError") {
168
+ throw new AutoICDError(0, `Request timed out after ${this.timeout}ms`);
169
+ }
170
+ throw err;
171
+ } finally {
172
+ clearTimeout(timer);
173
+ }
174
+ }
175
+ };
176
+ var Codes = class {
177
+ constructor(client) {
178
+ this.client = client;
179
+ }
180
+ /**
181
+ * Search ICD-10 codes by description.
182
+ *
183
+ * @example
184
+ * ```ts
185
+ * const results = await autoicd.codes.search("diabetes mellitus");
186
+ * ```
187
+ */
188
+ async search(query, options) {
189
+ const params = new URLSearchParams({ q: query });
190
+ if (options?.limit !== void 0) params.set("limit", String(options.limit));
191
+ if (options?.offset !== void 0) params.set("offset", String(options.offset));
192
+ return this.client.get(`/api/v1/codes/search?${params}`);
193
+ }
194
+ /**
195
+ * Get comprehensive details for a single ICD-10 code, including synonyms,
196
+ * hierarchy (parent/children), chapter, and SNOMED CT / UMLS cross-references.
197
+ *
198
+ * @example
199
+ * ```ts
200
+ * const detail = await autoicd.codes.get("E11.9");
201
+ * console.log(detail.long_description);
202
+ * console.log(detail.synonyms.snomed); // SNOMED CT synonyms
203
+ * console.log(detail.chapter?.title); // "Endocrine, Nutritional and Metabolic Diseases"
204
+ * console.log(detail.children.length); // child codes
205
+ * ```
206
+ */
207
+ async get(code) {
208
+ return this.client.get(`/api/v1/codes/${encodeURIComponent(code)}`);
209
+ }
210
+ };
211
+ var ICD11Codes = class {
212
+ constructor(client) {
213
+ this.client = client;
214
+ }
215
+ /**
216
+ * Search ICD-11 codes by description.
217
+ *
218
+ * @example
219
+ * ```ts
220
+ * const results = await autoicd.icd11.search("diabetes mellitus");
221
+ * ```
222
+ */
223
+ async search(query, options) {
224
+ const params = new URLSearchParams({ q: query });
225
+ if (options?.limit !== void 0) params.set("limit", String(options.limit));
226
+ if (options?.offset !== void 0) params.set("offset", String(options.offset));
227
+ return this.client.get(`/api/v1/icd11/codes/search?${params}`);
228
+ }
229
+ /**
230
+ * Get comprehensive details for a single ICD-11 code, including synonyms,
231
+ * hierarchy (parent/children), chapter, and ICD-10 crosswalk mappings.
232
+ *
233
+ * @example
234
+ * ```ts
235
+ * const detail = await autoicd.icd11.get("5A11");
236
+ * console.log(detail.long_description);
237
+ * console.log(detail.chapter?.title);
238
+ * console.log(detail.icd10_mappings);
239
+ * ```
240
+ */
241
+ async get(code) {
242
+ return this.client.get(`/api/v1/icd11/codes/${encodeURIComponent(code)}`);
243
+ }
244
+ };
245
+ function parseRateLimit(headers) {
246
+ const limit = headers.get("X-RateLimit-Limit");
247
+ const remaining = headers.get("X-RateLimit-Remaining");
248
+ const reset = headers.get("X-RateLimit-Reset");
249
+ if (!limit || !remaining || !reset) return null;
250
+ return {
251
+ limit: parseInt(limit, 10),
252
+ remaining: parseInt(remaining, 10),
253
+ resetAt: new Date(reset)
254
+ };
255
+ }
256
+ // Annotate the CommonJS export names for ESM import in node:
257
+ 0 && (module.exports = {
258
+ AuthenticationError,
259
+ AutoICD,
260
+ AutoICDError,
261
+ NotFoundError,
262
+ RateLimitError
263
+ });
264
+ //# sourceMappingURL=index.js.map
@@ -0,0 +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} 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} 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 codes: Codes;\n\n /** Sub-resource for ICD-11 code lookup. */\n readonly icd11: ICD11Codes;\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.codes = new Codes(this);\n this.icd11 = new ICD11Codes(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 });\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 // ─── 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// ─── Codes Sub-resource ───\n\nclass Codes {\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.codes.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/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.codes.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/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// ─── 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,IA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pF;AAEF;AAIA,IAAM,aAAN,MAAiB;AAAA,EACf,YAA6B,QAAiB;AAAjB;AAAA,EAAkB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAU/C,MAAM,OAAO,OAAe,SAA2D;AACrF,UAAM,SAAS,IAAI,gBAAgB,EAAE,GAAG,MAAM,CAAC;AAC/C,QAAI,SAAS,UAAU,OAAW,QAAO,IAAI,SAAS,OAAO,QAAQ,KAAK,CAAC;AAC3E,QAAI,SAAS,WAAW,OAAW,QAAO,IAAI,UAAU,OAAO,QAAQ,MAAM,CAAC;AAC9E,WAAO,KAAK,OAAO,IAA6B,8BAA8B,MAAM,EAAE;AAAA,EACxF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAcA,MAAM,IAAI,MAA4C;AACpD,WAAO,KAAK,OAAO,IAAyB,uBAAuB,mBAAmB,IAAI,CAAC,EAAE;AAAA,EAC/F;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 ADDED
@@ -0,0 +1,233 @@
1
+ // src/errors.ts
2
+ var AutoICDError = class extends Error {
3
+ status;
4
+ constructor(status, message) {
5
+ super(message);
6
+ this.name = "AutoICDError";
7
+ this.status = status;
8
+ }
9
+ };
10
+ var AuthenticationError = class extends AutoICDError {
11
+ constructor(message = "Invalid API key") {
12
+ super(401, message);
13
+ this.name = "AuthenticationError";
14
+ }
15
+ };
16
+ var RateLimitError = class extends AutoICDError {
17
+ rateLimit;
18
+ constructor(message, rateLimit) {
19
+ super(429, message);
20
+ this.name = "RateLimitError";
21
+ this.rateLimit = rateLimit;
22
+ }
23
+ };
24
+ var NotFoundError = class extends AutoICDError {
25
+ constructor(message = "Resource not found") {
26
+ super(404, message);
27
+ this.name = "NotFoundError";
28
+ }
29
+ };
30
+
31
+ // src/client.ts
32
+ var DEFAULT_BASE_URL = "https://autoicdapi.com";
33
+ var DEFAULT_TIMEOUT = 3e4;
34
+ var AutoICD = class {
35
+ apiKey;
36
+ baseURL;
37
+ timeout;
38
+ _fetch;
39
+ /** Rate limit info from the most recent API response. */
40
+ lastRateLimit = null;
41
+ /** Sub-resource for ICD-10 code lookup. */
42
+ codes;
43
+ /** Sub-resource for ICD-11 code lookup. */
44
+ icd11;
45
+ constructor(options) {
46
+ if (!options.apiKey) {
47
+ throw new Error("apiKey is required");
48
+ }
49
+ this.apiKey = options.apiKey;
50
+ this.baseURL = (options.baseURL ?? DEFAULT_BASE_URL).replace(/\/+$/, "");
51
+ this.timeout = options.timeout ?? DEFAULT_TIMEOUT;
52
+ this._fetch = options.fetch ?? globalThis.fetch;
53
+ this.codes = new Codes(this);
54
+ this.icd11 = new ICD11Codes(this);
55
+ }
56
+ // ─── Public Methods ───
57
+ /**
58
+ * Code clinical text to ICD-10-CM diagnoses.
59
+ *
60
+ * @example
61
+ * ```ts
62
+ * const result = await autoicd.code("Patient has type 2 diabetes");
63
+ * for (const entity of result.entities) {
64
+ * console.log(entity.entity_text, entity.codes[0]?.code);
65
+ * }
66
+ * ```
67
+ */
68
+ async code(text, options) {
69
+ return this.post("/api/v1/code", {
70
+ text,
71
+ top_k: options?.topK,
72
+ include_negated: options?.includeNegated,
73
+ output_system: options?.outputSystem
74
+ });
75
+ }
76
+ /**
77
+ * Anonymize PHI/PII in clinical text.
78
+ *
79
+ * @example
80
+ * ```ts
81
+ * const result = await autoicd.anonymize("John Smith, DOB 01/15/1980, has COPD");
82
+ * console.log(result.anonymized_text);
83
+ * // "[NAME], DOB [DATE], has COPD"
84
+ * ```
85
+ */
86
+ async anonymize(text) {
87
+ return this.post("/api/v1/anonymize", { text });
88
+ }
89
+ // ─── Internal HTTP ───
90
+ /** @internal */
91
+ async get(path) {
92
+ return this.request("GET", path);
93
+ }
94
+ /** @internal */
95
+ async post(path, body) {
96
+ const clean = Object.fromEntries(
97
+ Object.entries(body).filter(([, v]) => v !== void 0)
98
+ );
99
+ return this.request("POST", path, clean);
100
+ }
101
+ async request(method, path, body) {
102
+ const url = `${this.baseURL}${path}`;
103
+ const controller = new AbortController();
104
+ const timer = setTimeout(() => controller.abort(), this.timeout);
105
+ try {
106
+ const res = await this._fetch(url, {
107
+ method,
108
+ headers: {
109
+ Authorization: `Bearer ${this.apiKey}`,
110
+ "Content-Type": "application/json",
111
+ Accept: "application/json"
112
+ },
113
+ body: body ? JSON.stringify(body) : void 0,
114
+ signal: controller.signal
115
+ });
116
+ this.lastRateLimit = parseRateLimit(res.headers);
117
+ if (res.ok) {
118
+ return await res.json();
119
+ }
120
+ const errorBody = await res.json().catch(() => null);
121
+ const message = errorBody?.error ?? `HTTP ${res.status}`;
122
+ if (res.status === 401) throw new AuthenticationError(message);
123
+ if (res.status === 404) throw new NotFoundError(message);
124
+ if (res.status === 429) {
125
+ throw new RateLimitError(
126
+ message,
127
+ this.lastRateLimit ?? {
128
+ limit: errorBody?.limit ?? 0,
129
+ remaining: 0,
130
+ resetAt: errorBody?.resetAt ? new Date(errorBody.resetAt) : /* @__PURE__ */ new Date()
131
+ }
132
+ );
133
+ }
134
+ throw new AutoICDError(res.status, message);
135
+ } catch (err) {
136
+ if (err instanceof AutoICDError) throw err;
137
+ if (err instanceof DOMException && err.name === "AbortError") {
138
+ throw new AutoICDError(0, `Request timed out after ${this.timeout}ms`);
139
+ }
140
+ throw err;
141
+ } finally {
142
+ clearTimeout(timer);
143
+ }
144
+ }
145
+ };
146
+ var Codes = class {
147
+ constructor(client) {
148
+ this.client = client;
149
+ }
150
+ /**
151
+ * Search ICD-10 codes by description.
152
+ *
153
+ * @example
154
+ * ```ts
155
+ * const results = await autoicd.codes.search("diabetes mellitus");
156
+ * ```
157
+ */
158
+ async search(query, options) {
159
+ const params = new URLSearchParams({ q: query });
160
+ if (options?.limit !== void 0) params.set("limit", String(options.limit));
161
+ if (options?.offset !== void 0) params.set("offset", String(options.offset));
162
+ return this.client.get(`/api/v1/codes/search?${params}`);
163
+ }
164
+ /**
165
+ * Get comprehensive details for a single ICD-10 code, including synonyms,
166
+ * hierarchy (parent/children), chapter, and SNOMED CT / UMLS cross-references.
167
+ *
168
+ * @example
169
+ * ```ts
170
+ * const detail = await autoicd.codes.get("E11.9");
171
+ * console.log(detail.long_description);
172
+ * console.log(detail.synonyms.snomed); // SNOMED CT synonyms
173
+ * console.log(detail.chapter?.title); // "Endocrine, Nutritional and Metabolic Diseases"
174
+ * console.log(detail.children.length); // child codes
175
+ * ```
176
+ */
177
+ async get(code) {
178
+ return this.client.get(`/api/v1/codes/${encodeURIComponent(code)}`);
179
+ }
180
+ };
181
+ var ICD11Codes = class {
182
+ constructor(client) {
183
+ this.client = client;
184
+ }
185
+ /**
186
+ * Search ICD-11 codes by description.
187
+ *
188
+ * @example
189
+ * ```ts
190
+ * const results = await autoicd.icd11.search("diabetes mellitus");
191
+ * ```
192
+ */
193
+ async search(query, options) {
194
+ const params = new URLSearchParams({ q: query });
195
+ if (options?.limit !== void 0) params.set("limit", String(options.limit));
196
+ if (options?.offset !== void 0) params.set("offset", String(options.offset));
197
+ return this.client.get(`/api/v1/icd11/codes/search?${params}`);
198
+ }
199
+ /**
200
+ * Get comprehensive details for a single ICD-11 code, including synonyms,
201
+ * hierarchy (parent/children), chapter, and ICD-10 crosswalk mappings.
202
+ *
203
+ * @example
204
+ * ```ts
205
+ * const detail = await autoicd.icd11.get("5A11");
206
+ * console.log(detail.long_description);
207
+ * console.log(detail.chapter?.title);
208
+ * console.log(detail.icd10_mappings);
209
+ * ```
210
+ */
211
+ async get(code) {
212
+ return this.client.get(`/api/v1/icd11/codes/${encodeURIComponent(code)}`);
213
+ }
214
+ };
215
+ function parseRateLimit(headers) {
216
+ const limit = headers.get("X-RateLimit-Limit");
217
+ const remaining = headers.get("X-RateLimit-Remaining");
218
+ const reset = headers.get("X-RateLimit-Reset");
219
+ if (!limit || !remaining || !reset) return null;
220
+ return {
221
+ limit: parseInt(limit, 10),
222
+ remaining: parseInt(remaining, 10),
223
+ resetAt: new Date(reset)
224
+ };
225
+ }
226
+ export {
227
+ AuthenticationError,
228
+ AutoICD,
229
+ AutoICDError,
230
+ NotFoundError,
231
+ RateLimitError
232
+ };
233
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +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} 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 codes: Codes;\n\n /** Sub-resource for ICD-11 code lookup. */\n readonly icd11: ICD11Codes;\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.codes = new Codes(this);\n this.icd11 = new ICD11Codes(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 });\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 // ─── 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// ─── Codes Sub-resource ───\n\nclass Codes {\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.codes.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/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.codes.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/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// ─── 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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AAmB,IAAI,CAAC,EAAE;AAAA,EACpF;AAEF;AAIA,IAAM,aAAN,MAAiB;AAAA,EACf,YAA6B,QAAiB;AAAjB;AAAA,EAAkB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAU/C,MAAM,OAAO,OAAe,SAA2D;AACrF,UAAM,SAAS,IAAI,gBAAgB,EAAE,GAAG,MAAM,CAAC;AAC/C,QAAI,SAAS,UAAU,OAAW,QAAO,IAAI,SAAS,OAAO,QAAQ,KAAK,CAAC;AAC3E,QAAI,SAAS,WAAW,OAAW,QAAO,IAAI,UAAU,OAAO,QAAQ,MAAM,CAAC;AAC9E,WAAO,KAAK,OAAO,IAA6B,8BAA8B,MAAM,EAAE;AAAA,EACxF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAcA,MAAM,IAAI,MAA4C;AACpD,WAAO,KAAK,OAAO,IAAyB,uBAAuB,mBAAmB,IAAI,CAAC,EAAE;AAAA,EAC/F;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.5.0",
3
+ "version": "0.5.1",
4
4
  "description": "ICD-10 & ICD-11 medical coding SDK — convert clinical text to ICD-10-CM and ICD-11 diagnosis codes with AI-powered NLP. Automated medical 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",