@fhirfly-io/terminology 0.1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 FHIRfly.io LLC
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,213 @@
1
+ # @fhirfly-io/terminology
2
+
3
+ Official FHIRfly SDK for Node.js — typed access to healthcare reference data APIs (NDC, NPI, LOINC, RxNorm, ICD-10, CVX, MVX, FDA Labels).
4
+
5
+ [![npm version](https://img.shields.io/npm/v/@fhirfly-io/terminology.svg)](https://www.npmjs.com/package/@fhirfly-io/terminology)
6
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
7
+
8
+ ## Installation
9
+
10
+ ```bash
11
+ npm install @fhirfly-io/terminology
12
+ ```
13
+
14
+ ## Quick Start
15
+
16
+ ```typescript
17
+ import { Fhirfly } from "@fhirfly-io/terminology";
18
+
19
+ const client = new Fhirfly({ apiKey: "your-api-key" });
20
+
21
+ // Look up a drug by NDC
22
+ const ndc = await client.ndc.lookup("0069-0151-01");
23
+ console.log(ndc.data.product_name); // "Lipitor"
24
+
25
+ // Look up a provider by NPI
26
+ const npi = await client.npi.lookup("1234567890");
27
+ console.log(npi.data.name);
28
+ ```
29
+
30
+ ## Features
31
+
32
+ - **Full TypeScript support** with comprehensive type definitions
33
+ - **All FHIRfly APIs**: NDC, NPI, RxNorm, LOINC, ICD-10, CVX, MVX, FDA Labels
34
+ - **Batch lookups** for efficient bulk operations
35
+ - **Response shapes**: compact, standard, or full detail levels
36
+ - **Automatic retries** with exponential backoff
37
+ - **Detailed error types** for proper error handling
38
+ - **Designed for both human developers and programmatic agents**
39
+
40
+ ## API Reference
41
+
42
+ ### Client Configuration
43
+
44
+ ```typescript
45
+ const client = new Fhirfly({
46
+ apiKey: "your-api-key", // Required
47
+ baseUrl: "https://api.fhirfly.io", // Optional, default shown
48
+ timeout: 30000, // Optional, request timeout in ms
49
+ maxRetries: 3, // Optional, retry attempts
50
+ retryDelay: 1000, // Optional, base retry delay in ms
51
+ });
52
+ ```
53
+
54
+ ### NDC (National Drug Codes)
55
+
56
+ ```typescript
57
+ // Single lookup
58
+ const ndc = await client.ndc.lookup("0069-0151-01");
59
+
60
+ // With options
61
+ const ndc = await client.ndc.lookup("0069-0151-01", {
62
+ shape: "full", // "compact" | "standard" | "full"
63
+ include: ["display"], // Include pre-formatted display strings
64
+ });
65
+
66
+ // Batch lookup (up to 500 codes)
67
+ const results = await client.ndc.lookupMany([
68
+ "0069-0151-01",
69
+ "0069-0151-02",
70
+ ]);
71
+
72
+ for (const item of results.results) {
73
+ if (item.found) {
74
+ console.log(item.data.product_name);
75
+ }
76
+ }
77
+ ```
78
+
79
+ Batch lookups return per-item results and never throw for individual misses.
80
+
81
+ ### NPI (National Provider Identifiers)
82
+
83
+ ```typescript
84
+ // Single lookup
85
+ const npi = await client.npi.lookup("1234567890");
86
+
87
+ // Batch lookup
88
+ const results = await client.npi.lookupMany(["1234567890", "0987654321"]);
89
+ ```
90
+
91
+ ### RxNorm
92
+
93
+ ```typescript
94
+ // Look up by RxCUI
95
+ const rx = await client.rxnorm.lookup("213169");
96
+ console.log(rx.data.name); // "atorvastatin 10 MG Oral Tablet"
97
+ ```
98
+
99
+ ### LOINC
100
+
101
+ ```typescript
102
+ // Look up lab code
103
+ const loinc = await client.loinc.lookup("2345-7");
104
+ console.log(loinc.data.long_common_name);
105
+ ```
106
+
107
+ ### ICD-10
108
+
109
+ ```typescript
110
+ // ICD-10-CM (diagnoses)
111
+ const diagnosis = await client.icd10.lookupCm("E11.9");
112
+
113
+ // ICD-10-PCS (procedures)
114
+ const procedure = await client.icd10.lookupPcs("0BJ08ZZ");
115
+
116
+ // Batch lookups
117
+ const cmResults = await client.icd10.lookupCmMany(["E11.9", "I10"]);
118
+ const pcsResults = await client.icd10.lookupPcsMany(["0BJ08ZZ"]);
119
+ ```
120
+
121
+ ### CVX (Vaccine Codes)
122
+
123
+ ```typescript
124
+ const cvx = await client.cvx.lookup("208");
125
+ console.log(cvx.data.short_description);
126
+ ```
127
+
128
+ ### MVX (Vaccine Manufacturers)
129
+
130
+ ```typescript
131
+ const mvx = await client.mvx.lookup("PFR");
132
+ console.log(mvx.data.manufacturer_name); // "Pfizer, Inc"
133
+ ```
134
+
135
+ ### FDA Labels
136
+
137
+ ```typescript
138
+ // By Set ID
139
+ const label = await client.fdaLabels.lookup("set-id-here");
140
+
141
+ // By NDC
142
+ const label = await client.fdaLabels.lookupByNdc("0069-0151-01");
143
+ ```
144
+
145
+ ## Response Shapes
146
+
147
+ All lookup methods accept a `shape` option to control response detail:
148
+
149
+ | Shape | Description |
150
+ |-------|-------------|
151
+ | `compact` | Minimal fields for quick lookups |
152
+ | `standard` | Balanced detail (default) |
153
+ | `full` | Complete data with all available fields |
154
+
155
+ ```typescript
156
+ // Get full details
157
+ const ndc = await client.ndc.lookup("0069-0151-01", { shape: "full" });
158
+ ```
159
+
160
+ ## Error Handling
161
+
162
+ The SDK provides typed errors for different failure scenarios:
163
+
164
+ ```typescript
165
+ import {
166
+ Fhirfly,
167
+ NotFoundError,
168
+ RateLimitError,
169
+ AuthenticationError
170
+ } from "@fhirfly-io/terminology";
171
+
172
+ try {
173
+ const ndc = await client.ndc.lookup("invalid-code");
174
+ } catch (error) {
175
+ if (error instanceof NotFoundError) {
176
+ console.log(`Code not found: ${error.code_value}`);
177
+ } else if (error instanceof RateLimitError) {
178
+ console.log(`Rate limited. Retry after: ${error.retryAfter}s`);
179
+ } else if (error instanceof AuthenticationError) {
180
+ console.log("Invalid API key");
181
+ }
182
+ }
183
+ ```
184
+
185
+ ### Error Types
186
+
187
+ | Error | Status | Description |
188
+ |-------|--------|-------------|
189
+ | `AuthenticationError` | 401 | Invalid or missing API key |
190
+ | `NotFoundError` | 404 | Code/identifier not found |
191
+ | `ValidationError` | 400 | Invalid request parameters |
192
+ | `RateLimitError` | 429 | Rate limit exceeded |
193
+ | `QuotaExceededError` | 429 | Monthly quota exceeded |
194
+ | `ServerError` | 5xx | Server-side error |
195
+ | `NetworkError` | - | Network connectivity issue |
196
+ | `TimeoutError` | - | Request timed out |
197
+
198
+ `RateLimitError` indicates short-term throttling; `QuotaExceededError` indicates monthly plan limits.
199
+
200
+ ## Requirements
201
+
202
+ - Node.js 18+
203
+ - FHIRfly API key ([Get one free](https://fhirfly.io/dashboard))
204
+
205
+ ## License
206
+
207
+ MIT - see [LICENSE](./LICENSE) for details.
208
+
209
+ ## Links
210
+
211
+ - [FHIRfly Documentation](https://fhirfly.io/docs)
212
+ - [API Reference](https://fhirfly.io/docs/api-reference)
213
+ - [Get an API Key](https://fhirfly.io/dashboard)