@fhirfly-io/terminology 0.3.2 → 0.4.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/dist/index.cjs CHANGED
@@ -938,6 +938,155 @@ var FdaLabelsEndpoint = class {
938
938
  }
939
939
  };
940
940
 
941
+ // src/endpoints/connectivity.ts
942
+ var ConnectivityEndpoint = class {
943
+ constructor(http) {
944
+ this.http = http;
945
+ }
946
+ /**
947
+ * Look up connectivity options for a provider by NPI.
948
+ *
949
+ * Returns organizations linked to this NPI and their available endpoints
950
+ * (FHIR servers, Direct addresses, etc.) with verification evidence and
951
+ * availability metrics.
952
+ *
953
+ * @param npi - 10-digit NPI number
954
+ * @returns Connectivity information including endpoints and verification status
955
+ *
956
+ * @example
957
+ * ```ts
958
+ * const result = await client.connectivity.lookup("1234567890");
959
+ *
960
+ * console.log(`Provider: ${result.provider_summary.name}`);
961
+ * console.log(`Found ${result.connectivity_targets.length} organization(s)`);
962
+ *
963
+ * for (const target of result.connectivity_targets) {
964
+ * console.log(`\n${target.name} (${target.ehr_vendor || 'Unknown EHR'})`);
965
+ * console.log(` Link: ${target.link_type} (${target.link_confidence} confidence)`);
966
+ *
967
+ * for (const endpoint of target.endpoints) {
968
+ * console.log(` - ${endpoint.type}: ${endpoint.url}`);
969
+ * console.log(` Status: ${endpoint.status}`);
970
+ * if (endpoint.availability) {
971
+ * console.log(` Availability: ${endpoint.availability.percentage}%`);
972
+ * }
973
+ * }
974
+ * }
975
+ * ```
976
+ */
977
+ async lookup(npi) {
978
+ return this.http.get(
979
+ `/v1/npi/${encodeURIComponent(npi)}/connectivity`
980
+ );
981
+ }
982
+ };
983
+
984
+ // src/endpoints/snomed.ts
985
+ var SnomedEndpoint = class {
986
+ constructor(http) {
987
+ this.http = http;
988
+ }
989
+ /**
990
+ * Look up a single SNOMED CT concept by concept ID.
991
+ *
992
+ * @param conceptId - SNOMED concept ID (numeric string, e.g., "73211009")
993
+ * @returns SNOMED concept data with licensing metadata
994
+ *
995
+ * @example
996
+ * ```ts
997
+ * const result = await client.snomed.lookup("73211009");
998
+ * console.log(result.data.preferred_term); // "Diabetes mellitus"
999
+ * console.log(result.data.ips_category); // "condition"
1000
+ * ```
1001
+ */
1002
+ async lookup(conceptId) {
1003
+ return this.http.get(
1004
+ `/v1/snomed/${encodeURIComponent(conceptId)}`
1005
+ );
1006
+ }
1007
+ /**
1008
+ * Look up multiple SNOMED CT concepts in a single request.
1009
+ *
1010
+ * @param conceptIds - Array of SNOMED concept IDs (max 100)
1011
+ * @returns Batch response with results for each concept ID
1012
+ *
1013
+ * @example
1014
+ * ```ts
1015
+ * const result = await client.snomed.lookupMany(["73211009", "84114007"]);
1016
+ * for (const item of result.results) {
1017
+ * if (item.status === "ok") {
1018
+ * console.log(`${item.concept_id}: ${item.data.preferred_term}`);
1019
+ * }
1020
+ * }
1021
+ * ```
1022
+ */
1023
+ async lookupMany(conceptIds) {
1024
+ return this.http.post(
1025
+ "/v1/snomed/_batch",
1026
+ { concept_ids: conceptIds }
1027
+ );
1028
+ }
1029
+ /**
1030
+ * Search SNOMED CT IPS concepts.
1031
+ *
1032
+ * @param params - Search parameters (q, ips_category, semantic_tag, active, limit, skip)
1033
+ * @returns Search results with matching concepts
1034
+ *
1035
+ * @example
1036
+ * ```ts
1037
+ * // Text search
1038
+ * const results = await client.snomed.search({ q: "heart failure" });
1039
+ *
1040
+ * // Filter by category
1041
+ * const conditions = await client.snomed.search({
1042
+ * ips_category: "condition",
1043
+ * limit: 20
1044
+ * });
1045
+ * ```
1046
+ */
1047
+ async search(params) {
1048
+ return this.http.search("/v1/snomed/search", {
1049
+ ...params
1050
+ });
1051
+ }
1052
+ /**
1053
+ * List all available IPS categories.
1054
+ *
1055
+ * @returns Categories with descriptions
1056
+ *
1057
+ * @example
1058
+ * ```ts
1059
+ * const result = await client.snomed.categories();
1060
+ * console.log(result.categories); // ["substance", "product", "condition", ...]
1061
+ * ```
1062
+ */
1063
+ async categories() {
1064
+ return this.http.get("/v1/snomed/categories");
1065
+ }
1066
+ /**
1067
+ * Look up reverse mappings for a SNOMED concept.
1068
+ *
1069
+ * Returns what terminology codes (ICD-10, RxNorm, NDC) map to this SNOMED concept.
1070
+ *
1071
+ * @param conceptId - SNOMED concept ID (numeric string)
1072
+ * @returns Reverse mapping data showing source codes that map to this concept
1073
+ *
1074
+ * @example
1075
+ * ```ts
1076
+ * const result = await client.snomed.mappings("73211009");
1077
+ * console.log(result.data.snomed_display); // "Diabetes mellitus"
1078
+ * for (const mapping of result.data.mappings) {
1079
+ * console.log(`${mapping.source_system}: ${mapping.source_code}`);
1080
+ * }
1081
+ * ```
1082
+ */
1083
+ async mappings(conceptId) {
1084
+ return this.http.get(
1085
+ `/v1/snomed/${encodeURIComponent(conceptId)}/mappings`
1086
+ );
1087
+ }
1088
+ };
1089
+
941
1090
  // src/client.ts
942
1091
  var Fhirfly = class {
943
1092
  http;
@@ -973,6 +1122,16 @@ var Fhirfly = class {
973
1122
  * FDA drug label lookups.
974
1123
  */
975
1124
  fdaLabels;
1125
+ /**
1126
+ * Connectivity Intelligence lookups.
1127
+ * Find FHIR endpoints, Direct addresses, and other connectivity options for providers.
1128
+ */
1129
+ connectivity;
1130
+ /**
1131
+ * SNOMED CT IPS (International Patient Set) lookups.
1132
+ * Look up clinical concepts from the SNOMED CT IPS free set (~12K concepts, CC BY 4.0).
1133
+ */
1134
+ snomed;
976
1135
  /**
977
1136
  * Create a new FHIRfly client.
978
1137
  *
@@ -1018,6 +1177,8 @@ var Fhirfly = class {
1018
1177
  this.cvx = new CvxEndpoint(this.http);
1019
1178
  this.mvx = new MvxEndpoint(this.http);
1020
1179
  this.fdaLabels = new FdaLabelsEndpoint(this.http);
1180
+ this.connectivity = new ConnectivityEndpoint(this.http);
1181
+ this.snomed = new SnomedEndpoint(this.http);
1021
1182
  }
1022
1183
  };
1023
1184
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/errors.ts","../src/http.ts","../src/endpoints/ndc.ts","../src/endpoints/npi.ts","../src/endpoints/rxnorm.ts","../src/endpoints/loinc.ts","../src/endpoints/icd10.ts","../src/endpoints/cvx.ts","../src/endpoints/mvx.ts","../src/endpoints/fda-labels.ts","../src/client.ts"],"names":[],"mappings":";;;AAGO,IAAM,YAAA,GAAN,MAAM,aAAA,SAAqB,KAAA,CAAM;AAAA,EACtC,YAAY,OAAA,EAAiB;AAC3B,IAAA,KAAA,CAAM,OAAO,CAAA;AACb,IAAA,IAAA,CAAK,IAAA,GAAO,cAAA;AACZ,IAAA,MAAA,CAAO,cAAA,CAAe,IAAA,EAAM,aAAA,CAAa,SAAS,CAAA;AAAA,EACpD;AACF;AAKO,IAAM,QAAA,GAAN,MAAM,SAAA,SAAiB,YAAA,CAAa;AAAA,EAChC,UAAA;AAAA,EACA,IAAA;AAAA,EACA,OAAA;AAAA,EAET,WAAA,CACE,OAAA,EACA,UAAA,EACA,IAAA,EACA,OAAA,EACA;AACA,IAAA,KAAA,CAAM,OAAO,CAAA;AACb,IAAA,IAAA,CAAK,IAAA,GAAO,UAAA;AACZ,IAAA,IAAA,CAAK,UAAA,GAAa,UAAA;AAClB,IAAA,IAAA,CAAK,IAAA,GAAO,IAAA;AACZ,IAAA,IAAA,CAAK,OAAA,GAAU,OAAA;AACf,IAAA,MAAA,CAAO,cAAA,CAAe,IAAA,EAAM,SAAA,CAAS,SAAS,CAAA;AAAA,EAChD;AACF;AAKO,IAAM,mBAAA,GAAN,MAAM,oBAAA,SAA4B,QAAA,CAAS;AAAA,EAChD,WAAA,CAAY,UAAU,4CAAA,EAA8C;AAClE,IAAA,KAAA,CAAM,OAAA,EAAS,KAAK,sBAAsB,CAAA;AAC1C,IAAA,IAAA,CAAK,IAAA,GAAO,qBAAA;AACZ,IAAA,MAAA,CAAO,cAAA,CAAe,IAAA,EAAM,oBAAA,CAAoB,SAAS,CAAA;AAAA,EAC3D;AACF;AAKO,IAAM,aAAA,GAAN,MAAM,cAAA,SAAsB,QAAA,CAAS;AA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CAAK,IAAI,CAAA;AACxC,IAAA,IAAA,CAAK,GAAA,GAAM,IAAI,WAAA,CAAY,IAAA,CAAK,IAAI,CAAA;AACpC,IAAA,IAAA,CAAK,GAAA,GAAM,IAAI,WAAA,CAAY,IAAA,CAAK,IAAI,CAAA;AACpC,IAAA,IAAA,CAAK,SAAA,GAAY,IAAI,iBAAA,CAAkB,IAAA,CAAK,IAAI,CAAA;AAAA,EAClD;AACF","file":"index.cjs","sourcesContent":["/**\n * Base error class for all FHIRfly SDK errors.\n */\nexport class FhirflyError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"FhirflyError\";\n Object.setPrototypeOf(this, FhirflyError.prototype);\n }\n}\n\n/**\n * Error thrown when the API returns an error response.\n */\nexport class ApiError extends FhirflyError {\n readonly statusCode: number;\n readonly code?: string;\n readonly details?: unknown;\n\n constructor(\n message: string,\n statusCode: number,\n code?: string,\n details?: unknown\n ) {\n super(message);\n this.name = \"ApiError\";\n this.statusCode = statusCode;\n this.code = code;\n this.details = details;\n Object.setPrototypeOf(this, ApiError.prototype);\n }\n}\n\n/**\n * Error thrown when authentication fails (401).\n */\nexport class AuthenticationError extends ApiError {\n constructor(message = \"Authentication failed. Check your API key.\") {\n super(message, 401, \"AUTHENTICATION_ERROR\");\n this.name = \"AuthenticationError\";\n Object.setPrototypeOf(this, AuthenticationError.prototype);\n }\n}\n\n/**\n * Error thrown when a resource is not found (404).\n */\nexport class NotFoundError extends ApiError {\n readonly code_type: string;\n readonly code_value: string;\n\n constructor(codeType: string, codeValue: string) {\n super(`${codeType} not found: ${codeValue}`, 404, \"NOT_FOUND\");\n this.name = \"NotFoundError\";\n this.code_type = codeType;\n this.code_value = codeValue;\n Object.setPrototypeOf(this, NotFoundError.prototype);\n }\n}\n\n/**\n * Error thrown when the request is invalid (400).\n */\nexport class ValidationError extends ApiError {\n readonly field?: string;\n\n constructor(message: string, field?: string) {\n super(message, 400, \"VALIDATION_ERROR\");\n this.name = \"ValidationError\";\n this.field = field;\n Object.setPrototypeOf(this, ValidationError.prototype);\n }\n}\n\n/**\n * Error thrown when rate limited (429).\n */\nexport class RateLimitError extends ApiError {\n readonly retryAfter?: number;\n readonly limit?: number;\n readonly remaining?: number;\n readonly reset?: Date;\n\n constructor(\n message = \"Rate limit exceeded\",\n retryAfter?: number,\n limit?: number,\n remaining?: number,\n reset?: Date\n ) {\n super(message, 429, \"RATE_LIMIT_EXCEEDED\");\n this.name = \"RateLimitError\";\n this.retryAfter = retryAfter;\n this.limit = limit;\n this.remaining = remaining;\n this.reset = reset;\n Object.setPrototypeOf(this, RateLimitError.prototype);\n }\n}\n\n/**\n * Error thrown when quota is exceeded (429 with quota context).\n */\nexport class QuotaExceededError extends ApiError {\n readonly quotaLimit?: number;\n readonly quotaUsed?: number;\n readonly quotaResetDate?: Date;\n\n constructor(\n message = \"Monthly quota exceeded\",\n quotaLimit?: number,\n quotaUsed?: number,\n quotaResetDate?: Date\n ) {\n super(message, 429, \"QUOTA_EXCEEDED\");\n this.name = \"QuotaExceededError\";\n this.quotaLimit = quotaLimit;\n this.quotaUsed = quotaUsed;\n this.quotaResetDate = quotaResetDate;\n Object.setPrototypeOf(this, QuotaExceededError.prototype);\n }\n}\n\n/**\n * Error thrown when the server returns a 5xx error.\n */\nexport class ServerError extends ApiError {\n constructor(message = \"Server error\", statusCode = 500) {\n super(message, statusCode, \"SERVER_ERROR\");\n this.name = \"ServerError\";\n Object.setPrototypeOf(this, ServerError.prototype);\n }\n}\n\n/**\n * Error thrown when a network error occurs.\n */\nexport class NetworkError extends FhirflyError {\n readonly cause?: Error;\n\n constructor(message = \"Network error\", cause?: Error) {\n super(message);\n this.name = \"NetworkError\";\n this.cause = cause;\n Object.setPrototypeOf(this, NetworkError.prototype);\n }\n}\n\n/**\n * Error thrown when a request times out.\n */\nexport class TimeoutError extends FhirflyError {\n readonly timeoutMs: number;\n\n constructor(timeoutMs: number) {\n super(`Request timed out after ${timeoutMs}ms`);\n this.name = \"TimeoutError\";\n this.timeoutMs = timeoutMs;\n Object.setPrototypeOf(this, TimeoutError.prototype);\n }\n}\n","import {\n ApiError,\n AuthenticationError,\n NetworkError,\n NotFoundError,\n QuotaExceededError,\n RateLimitError,\n ServerError,\n TimeoutError,\n ValidationError,\n} from \"./errors.js\";\nimport type { LookupOptions } from \"./types/common.js\";\n\n/**\n * OAuth2 token response from the token endpoint.\n */\ninterface TokenResponse {\n access_token: string;\n token_type: string;\n expires_in: number;\n scope?: string;\n}\n\n/**\n * OAuth2 client credentials configuration.\n */\nexport interface OAuthCredentials {\n clientId: string;\n clientSecret: string;\n tokenUrl: string;\n scopes?: string[];\n}\n\n/**\n * Manages OAuth2 access tokens with automatic refresh.\n */\nexport class TokenManager {\n private readonly credentials: OAuthCredentials;\n private accessToken: string | null = null;\n private expiresAt = 0;\n private refreshPromise: Promise<string> | null = null;\n\n constructor(credentials: OAuthCredentials) {\n this.credentials = credentials;\n }\n\n /**\n * Get a valid access token, refreshing if needed.\n * Deduplicates concurrent refresh calls.\n */\n async getToken(): Promise<string> {\n if (this.accessToken && Date.now() < this.expiresAt) {\n return this.accessToken;\n }\n if (this.refreshPromise) {\n return this.refreshPromise;\n }\n this.refreshPromise = this.fetchToken();\n try {\n return await this.refreshPromise;\n } finally {\n this.refreshPromise = null;\n }\n }\n\n /**\n * Invalidate the cached token (e.g., after a 401 response).\n */\n invalidate(): void {\n this.accessToken = null;\n this.expiresAt = 0;\n }\n\n private async fetchToken(): Promise<string> {\n const body = new URLSearchParams({\n grant_type: \"client_credentials\",\n client_id: this.credentials.clientId,\n client_secret: this.credentials.clientSecret,\n });\n if (this.credentials.scopes?.length) {\n body.set(\"scope\", this.credentials.scopes.join(\" \"));\n }\n\n const response = await fetch(this.credentials.tokenUrl, {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/x-www-form-urlencoded\" },\n body: body.toString(),\n });\n\n if (!response.ok) {\n const text = await response.text().catch(() => \"\");\n throw new AuthenticationError(\n `OAuth2 token exchange failed (${response.status}): ${text}`\n );\n }\n\n const data = (await response.json()) as TokenResponse;\n this.accessToken = data.access_token;\n // Refresh 60s before expiry\n this.expiresAt = Date.now() + (data.expires_in - 60) * 1000;\n return this.accessToken;\n }\n}\n\n/**\n * Authentication mode for the HTTP client.\n */\ntype AuthMode =\n | { type: \"api-key\"; apiKey: string }\n | { type: \"oauth\"; tokenManager: TokenManager };\n\n/**\n * HTTP client configuration.\n */\nexport interface HttpClientConfig {\n baseUrl: string;\n auth: AuthMode;\n timeout?: number;\n maxRetries?: number;\n retryDelay?: number;\n userAgent?: string;\n}\n\n/**\n * HTTP response from the API.\n */\ninterface HttpResponse<T> {\n data: T;\n status: number;\n headers: Headers;\n}\n\n/**\n * Internal HTTP client for making API requests.\n */\nexport class HttpClient {\n private readonly config: Required<Omit<HttpClientConfig, \"auth\">> & { auth: AuthMode };\n\n constructor(config: HttpClientConfig) {\n this.config = {\n baseUrl: config.baseUrl,\n auth: config.auth,\n timeout: config.timeout ?? 30000,\n maxRetries: config.maxRetries ?? 3,\n retryDelay: config.retryDelay ?? 1000,\n userAgent: config.userAgent ?? `@fhirfly/sdk/0.1.0 Node.js/${process.version}`,\n };\n }\n\n /**\n * Build query string from options.\n */\n private buildQueryString(options?: LookupOptions): string {\n if (!options) return \"\";\n\n const params = new URLSearchParams();\n\n if (options.shape) {\n params.set(\"shape\", options.shape);\n }\n\n if (options.include?.length) {\n params.set(\"include\", options.include.join(\",\"));\n }\n\n const queryString = params.toString();\n return queryString ? `?${queryString}` : \"\";\n }\n\n /**\n * Build query string from search params object.\n */\n buildSearchQueryString(params: Record<string, unknown>): string {\n const searchParams = new URLSearchParams();\n\n for (const [key, value] of Object.entries(params)) {\n if (value === undefined || value === null) continue;\n\n if (typeof value === \"boolean\") {\n searchParams.set(key, value.toString());\n } else if (typeof value === \"number\") {\n searchParams.set(key, value.toString());\n } else if (typeof value === \"string\" && value.length > 0) {\n searchParams.set(key, value);\n } else if (Array.isArray(value) && value.length > 0) {\n searchParams.set(key, value.join(\",\"));\n }\n }\n\n const queryString = searchParams.toString();\n return queryString ? `?${queryString}` : \"\";\n }\n\n /**\n * Parse error response from API.\n */\n private async parseErrorResponse(\n response: Response,\n endpoint: string\n ): Promise<never> {\n const status = response.status;\n let body: { message?: string; code?: string; error?: string; details?: unknown } = {};\n\n try {\n body = await response.json() as typeof body;\n } catch {\n // Response body is not JSON\n }\n\n const message = body.message || body.error || response.statusText;\n\n // Handle specific status codes\n switch (status) {\n case 401:\n throw new AuthenticationError(message);\n\n case 404: {\n // Extract code type and value from endpoint\n const match = endpoint.match(/\\/v1\\/(\\w+)\\/(.+)/);\n if (match) {\n throw new NotFoundError(match[1]!.toUpperCase(), match[2]!);\n }\n throw new NotFoundError(\"Resource\", endpoint);\n }\n\n case 400:\n throw new ValidationError(message);\n\n case 429: {\n const retryAfter = response.headers.get(\"retry-after\");\n const limit = response.headers.get(\"x-ratelimit-limit\");\n const remaining = response.headers.get(\"x-ratelimit-remaining\");\n const reset = response.headers.get(\"x-ratelimit-reset\");\n\n // Check if it's a quota error vs rate limit\n if (body.code === \"QUOTA_EXCEEDED\") {\n throw new QuotaExceededError(message);\n }\n\n throw new RateLimitError(\n message,\n retryAfter ? parseInt(retryAfter, 10) : undefined,\n limit ? parseInt(limit, 10) : undefined,\n remaining ? parseInt(remaining, 10) : undefined,\n reset ? new Date(parseInt(reset, 10) * 1000) : undefined\n );\n }\n\n default:\n if (status >= 500) {\n throw new ServerError(message, status);\n }\n throw new ApiError(message, status, body.code, body.details);\n }\n }\n\n /**\n * Sleep for a given number of milliseconds.\n */\n private sleep(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n }\n\n /**\n * Get auth headers for the current request.\n */\n private async getAuthHeaders(): Promise<Record<string, string>> {\n if (this.config.auth.type === \"api-key\") {\n return { \"x-api-key\": this.config.auth.apiKey };\n }\n const token = await this.config.auth.tokenManager.getToken();\n return { \"Authorization\": `Bearer ${token}` };\n }\n\n /**\n * Make an HTTP request with retries.\n */\n private async request<T>(\n method: \"GET\" | \"POST\",\n endpoint: string,\n body?: unknown,\n isRetryAfter401 = false\n ): Promise<HttpResponse<T>> {\n const url = `${this.config.baseUrl}${endpoint}`;\n let lastError: Error | undefined;\n\n for (let attempt = 0; attempt <= this.config.maxRetries; attempt++) {\n try {\n const controller = new AbortController();\n const timeoutId = setTimeout(\n () => controller.abort(),\n this.config.timeout\n );\n\n const authHeaders = await this.getAuthHeaders();\n\n const response = await fetch(url, {\n method,\n headers: {\n ...authHeaders,\n \"Content-Type\": \"application/json\",\n \"User-Agent\": this.config.userAgent,\n \"Accept\": \"application/json\",\n },\n body: body ? JSON.stringify(body) : undefined,\n signal: controller.signal,\n });\n\n clearTimeout(timeoutId);\n\n if (!response.ok) {\n // On 401 with OAuth, invalidate token and retry once\n if (\n response.status === 401 &&\n this.config.auth.type === \"oauth\" &&\n !isRetryAfter401\n ) {\n this.config.auth.tokenManager.invalidate();\n return this.request<T>(method, endpoint, body, true);\n }\n\n // Don't retry client errors (except rate limits)\n if (response.status < 500 && response.status !== 429) {\n await this.parseErrorResponse(response, endpoint);\n }\n\n // For rate limits, check retry-after header\n if (response.status === 429) {\n const retryAfter = response.headers.get(\"retry-after\");\n if (retryAfter && attempt < this.config.maxRetries) {\n await this.sleep(parseInt(retryAfter, 10) * 1000);\n continue;\n }\n await this.parseErrorResponse(response, endpoint);\n }\n\n // Retry server errors\n if (attempt < this.config.maxRetries) {\n await this.sleep(this.config.retryDelay * Math.pow(2, attempt));\n continue;\n }\n\n await this.parseErrorResponse(response, endpoint);\n }\n\n const data = await response.json() as T;\n return { data, status: response.status, headers: response.headers };\n } catch (error) {\n if (error instanceof ApiError) {\n throw error;\n }\n\n if (error instanceof Error) {\n if (error.name === \"AbortError\") {\n throw new TimeoutError(this.config.timeout);\n }\n\n lastError = error;\n\n // Retry on network errors\n if (attempt < this.config.maxRetries) {\n await this.sleep(this.config.retryDelay * Math.pow(2, attempt));\n continue;\n }\n }\n\n throw new NetworkError(\n lastError?.message || \"Unknown network error\",\n lastError\n );\n }\n }\n\n throw new NetworkError(\n lastError?.message || \"Request failed after retries\",\n lastError\n );\n }\n\n /**\n * Make a GET request.\n */\n async get<T>(endpoint: string, options?: LookupOptions): Promise<T> {\n const queryString = this.buildQueryString(options);\n const response = await this.request<T>(\"GET\", `${endpoint}${queryString}`);\n return response.data;\n }\n\n /**\n * Make a POST request.\n */\n async post<T>(endpoint: string, body: unknown, options?: LookupOptions): Promise<T> {\n const queryString = this.buildQueryString(options);\n const response = await this.request<T>(\"POST\", `${endpoint}${queryString}`, body);\n return response.data;\n }\n\n /**\n * Make a GET request with search parameters.\n */\n async search<T>(endpoint: string, params: Record<string, unknown>): Promise<T> {\n const queryString = this.buildSearchQueryString(params);\n const response = await this.request<T>(\"GET\", `${endpoint}${queryString}`);\n return response.data;\n }\n}\n","import type { HttpClient } from \"../http.js\";\nimport type {\n ApiResponse,\n BatchResponse,\n LookupOptions,\n BatchLookupOptions,\n SearchOptions,\n SearchResponse,\n} from \"../types/common.js\";\nimport type { NdcData, NdcSearchParams } from \"../types/ndc.js\";\n\n/**\n * NDC (National Drug Code) API endpoint.\n */\nexport class NdcEndpoint {\n constructor(private readonly http: HttpClient) {}\n\n /**\n * Look up a single NDC code.\n *\n * @param code - NDC code (10-digit, 11-digit, or hyphenated format)\n * @param options - Response shape and include options\n * @returns NDC data\n *\n * @example\n * ```ts\n * const ndc = await client.ndc.lookup(\"0069-0151-01\");\n * console.log(ndc.data.product_name); // \"Lipitor\"\n * ```\n */\n async lookup(code: string, options?: LookupOptions): Promise<ApiResponse<NdcData>> {\n return this.http.get<ApiResponse<NdcData>>(`/v1/ndc/${encodeURIComponent(code)}`, options);\n }\n\n /**\n * Look up multiple NDC codes in a single request.\n *\n * @param codes - Array of NDC codes (max 500)\n * @param options - Response shape, include, and batch options\n * @returns Batch response with results for each code\n *\n * @example\n * ```ts\n * const results = await client.ndc.lookupMany([\n * \"0069-0151-01\",\n * \"0069-0151-02\",\n * \"invalid-code\"\n * ]);\n *\n * for (const item of results.results) {\n * if (item.found) {\n * console.log(item.data.product_name);\n * } else {\n * console.log(`Not found: ${item.code}`);\n * }\n * }\n * ```\n */\n async lookupMany(\n codes: string[],\n options?: BatchLookupOptions\n ): Promise<BatchResponse<NdcData>> {\n return this.http.post<BatchResponse<NdcData>>(\n \"/v1/ndc/_batch\",\n { codes },\n options\n );\n }\n\n /**\n * Search for NDC products.\n *\n * @param params - Search parameters (q, name, brand, ingredient, etc.)\n * @param options - Pagination and response shape options\n * @returns Search results with facets\n *\n * @example\n * ```ts\n * // Search by drug name\n * const results = await client.ndc.search({ q: \"advil\" });\n *\n * // Search with filters\n * const results = await client.ndc.search({\n * ingredient: \"ibuprofen\",\n * dosage_form: \"TABLET\",\n * product_type: \"otc\"\n * });\n *\n * console.log(`Found ${results.total} products`);\n * for (const item of results.items) {\n * console.log(item.product_name);\n * }\n * ```\n */\n async search(\n params: NdcSearchParams,\n options?: SearchOptions\n ): Promise<SearchResponse<NdcData>> {\n return this.http.search<SearchResponse<NdcData>>(\"/v1/ndc/search\", {\n ...params,\n ...options,\n include: options?.include?.join(\",\"),\n });\n }\n}\n","import type { HttpClient } from \"../http.js\";\nimport type {\n ApiResponse,\n BatchResponse,\n LookupOptions,\n BatchLookupOptions,\n SearchOptions,\n SearchResponse,\n} from \"../types/common.js\";\nimport type { NpiData, NpiSearchParams } from \"../types/npi.js\";\n\n/**\n * NPI (National Provider Identifier) API endpoint.\n */\nexport class NpiEndpoint {\n constructor(private readonly http: HttpClient) {}\n\n /**\n * Look up a single NPI.\n *\n * @param npi - 10-digit NPI number\n * @param options - Response shape and include options\n * @returns NPI data\n *\n * @example\n * ```ts\n * const npi = await client.npi.lookup(\"1234567890\");\n * console.log(npi.data.name);\n * ```\n */\n async lookup(npi: string, options?: LookupOptions): Promise<ApiResponse<NpiData>> {\n return this.http.get<ApiResponse<NpiData>>(`/v1/npi/${encodeURIComponent(npi)}`, options);\n }\n\n /**\n * Look up multiple NPIs in a single request.\n *\n * @param npis - Array of 10-digit NPI numbers (max 500)\n * @param options - Response shape, include, and batch options\n * @returns Batch response with results for each NPI\n *\n * @example\n * ```ts\n * const results = await client.npi.lookupMany([\n * \"1234567890\",\n * \"0987654321\"\n * ]);\n * ```\n */\n async lookupMany(\n npis: string[],\n options?: BatchLookupOptions\n ): Promise<BatchResponse<NpiData>> {\n return this.http.post<BatchResponse<NpiData>>(\n \"/v1/npi/_batch\",\n { npis },\n options\n );\n }\n\n /**\n * Search for healthcare providers.\n *\n * @param params - Search parameters (q, name, specialty, state, etc.)\n * @param options - Pagination and response shape options\n * @returns Search results with facets\n *\n * @example\n * ```ts\n * // Search by name\n * const results = await client.npi.search({ q: \"smith\" });\n *\n * // Search with filters\n * const results = await client.npi.search({\n * specialty: \"cardiology\",\n * state: \"CA\",\n * entity_type: \"individual\"\n * });\n *\n * console.log(`Found ${results.total} providers`);\n * ```\n */\n async search(\n params: NpiSearchParams,\n options?: SearchOptions\n ): Promise<SearchResponse<NpiData>> {\n return this.http.search<SearchResponse<NpiData>>(\"/v1/npi/search\", {\n ...params,\n ...options,\n include: options?.include?.join(\",\"),\n });\n }\n}\n","import type { HttpClient } from \"../http.js\";\nimport type {\n ApiResponse,\n BatchResponse,\n LookupOptions,\n BatchLookupOptions,\n SearchOptions,\n SearchResponse,\n} from \"../types/common.js\";\nimport type { RxNormData, RxNormSearchParams } from \"../types/rxnorm.js\";\n\n/**\n * RxNorm API endpoint.\n */\nexport class RxNormEndpoint {\n constructor(private readonly http: HttpClient) {}\n\n /**\n * Look up a single RxCUI.\n *\n * @param rxcui - RxNorm Concept Unique Identifier\n * @param options - Response shape and include options\n * @returns RxNorm data\n *\n * @example\n * ```ts\n * const rx = await client.rxnorm.lookup(\"213169\");\n * console.log(rx.data.name); // \"atorvastatin 10 MG Oral Tablet\"\n * ```\n */\n async lookup(rxcui: string, options?: LookupOptions): Promise<ApiResponse<RxNormData>> {\n return this.http.get<ApiResponse<RxNormData>>(`/v1/rxnorm/${encodeURIComponent(rxcui)}`, options);\n }\n\n /**\n * Look up multiple RxCUIs in a single request.\n *\n * @param rxcuis - Array of RxCUIs (max 500)\n * @param options - Response shape, include, and batch options\n * @returns Batch response with results for each RxCUI\n */\n async lookupMany(\n rxcuis: string[],\n options?: BatchLookupOptions\n ): Promise<BatchResponse<RxNormData>> {\n return this.http.post<BatchResponse<RxNormData>>(\n \"/v1/rxnorm/_batch\",\n { rxcuis },\n options\n );\n }\n\n /**\n * Search for drugs in RxNorm.\n *\n * @param params - Search parameters (q, name, ingredient, brand, etc.)\n * @param options - Pagination and response shape options\n * @returns Search results with facets\n *\n * @example\n * ```ts\n * // Search by drug name\n * const results = await client.rxnorm.search({ q: \"lipitor\" });\n *\n * // Search prescribable drugs by ingredient\n * const results = await client.rxnorm.search({\n * ingredient: \"metformin\",\n * is_prescribable: true\n * });\n * ```\n */\n async search(\n params: RxNormSearchParams,\n options?: SearchOptions\n ): Promise<SearchResponse<RxNormData>> {\n return this.http.search<SearchResponse<RxNormData>>(\"/v1/rxnorm/search\", {\n ...params,\n ...options,\n include: options?.include?.join(\",\"),\n });\n }\n}\n","import type { HttpClient } from \"../http.js\";\nimport type {\n ApiResponse,\n BatchResponse,\n LookupOptions,\n BatchLookupOptions,\n SearchOptions,\n SearchResponse,\n} from \"../types/common.js\";\nimport type { LoincData, LoincSearchParams } from \"../types/loinc.js\";\n\n/**\n * LOINC API endpoint.\n */\nexport class LoincEndpoint {\n constructor(private readonly http: HttpClient) {}\n\n /**\n * Look up a single LOINC code.\n *\n * @param loincNum - LOINC number (e.g., \"2345-7\")\n * @param options - Response shape and include options\n * @returns LOINC data\n *\n * @example\n * ```ts\n * const loinc = await client.loinc.lookup(\"2345-7\");\n * console.log(loinc.data.long_common_name); // \"Glucose [Mass/volume] in Serum or Plasma\"\n * ```\n */\n async lookup(loincNum: string, options?: LookupOptions): Promise<ApiResponse<LoincData>> {\n return this.http.get<ApiResponse<LoincData>>(`/v1/loinc/${encodeURIComponent(loincNum)}`, options);\n }\n\n /**\n * Look up multiple LOINC codes in a single request.\n *\n * @param loincNums - Array of LOINC numbers (max 500)\n * @param options - Response shape, include, and batch options\n * @returns Batch response with results for each LOINC\n */\n async lookupMany(\n loincNums: string[],\n options?: BatchLookupOptions\n ): Promise<BatchResponse<LoincData>> {\n return this.http.post<BatchResponse<LoincData>>(\n \"/v1/loinc/_batch\",\n { codes: loincNums },\n options\n );\n }\n\n /**\n * Search for LOINC codes.\n *\n * @param params - Search parameters (q, component, class, system, etc.)\n * @param options - Pagination and response shape options\n * @returns Search results with facets\n *\n * @example\n * ```ts\n * // Search by term\n * const results = await client.loinc.search({ q: \"glucose\" });\n *\n * // Search blood chemistry tests\n * const results = await client.loinc.search({\n * class: \"CHEM\",\n * system: \"Bld\",\n * scale: \"Qn\"\n * });\n * ```\n */\n async search(\n params: LoincSearchParams,\n options?: SearchOptions\n ): Promise<SearchResponse<LoincData>> {\n return this.http.search<SearchResponse<LoincData>>(\"/v1/loinc/search\", {\n ...params,\n ...options,\n include: options?.include?.join(\",\"),\n });\n }\n}\n","import type { HttpClient } from \"../http.js\";\nimport type {\n ApiResponse,\n BatchResponse,\n LookupOptions,\n BatchLookupOptions,\n SearchOptions,\n SearchResponse,\n} from \"../types/common.js\";\nimport type { Icd10Data, Icd10SearchParams } from \"../types/icd10.js\";\n\n/**\n * ICD-10 API endpoint.\n */\nexport class Icd10Endpoint {\n constructor(private readonly http: HttpClient) {}\n\n /**\n * Look up a single ICD-10 code (CM or PCS).\n *\n * The API auto-detects whether the code is CM (diagnoses) or PCS (procedures)\n * based on the code format.\n *\n * @param code - ICD-10 code (e.g., \"E11.9\" for CM, \"02HA0QZ\" for PCS)\n * @param options - Response shape and include options\n * @returns ICD-10 data\n *\n * @example\n * ```ts\n * // Diagnosis code (CM)\n * const diagnosis = await client.icd10.lookup(\"E11.9\");\n * console.log(diagnosis.data.description); // \"Type 2 diabetes mellitus without complications\"\n *\n * // Procedure code (PCS)\n * const procedure = await client.icd10.lookup(\"02HA0QZ\");\n * console.log(procedure.data.description);\n * ```\n */\n async lookup(code: string, options?: LookupOptions): Promise<ApiResponse<Icd10Data>> {\n return this.http.get<ApiResponse<Icd10Data>>(`/v1/icd10/${encodeURIComponent(code)}`, options);\n }\n\n /**\n * Look up multiple ICD-10 codes in a single request.\n *\n * Codes can be a mix of CM (diagnoses) and PCS (procedures).\n *\n * @param codes - Array of ICD-10 codes (max 500)\n * @param options - Response shape, include, and batch options\n * @returns Batch response with results for each code\n */\n async lookupMany(\n codes: string[],\n options?: BatchLookupOptions\n ): Promise<BatchResponse<Icd10Data>> {\n return this.http.post<BatchResponse<Icd10Data>>(\n \"/v1/icd10/_batch\",\n { codes },\n options\n );\n }\n\n /**\n * Search for ICD-10 codes (both CM and PCS).\n *\n * @param params - Search parameters (q, code_system, chapter, billable, etc.)\n * @param options - Pagination and response shape options\n * @returns Search results with facets\n *\n * @example\n * ```ts\n * // Search diagnosis codes\n * const results = await client.icd10.search({\n * q: \"diabetes\",\n * code_system: \"CM\",\n * billable: true\n * });\n *\n * // Search procedure codes\n * const results = await client.icd10.search({\n * q: \"bypass\",\n * code_system: \"PCS\"\n * });\n * ```\n */\n async search(\n params: Icd10SearchParams,\n options?: SearchOptions\n ): Promise<SearchResponse<Icd10Data>> {\n return this.http.search<SearchResponse<Icd10Data>>(\"/v1/icd10/search\", {\n ...params,\n ...options,\n include: options?.include?.join(\",\"),\n });\n }\n}\n","import type { HttpClient } from \"../http.js\";\nimport type {\n ApiResponse,\n BatchResponse,\n LookupOptions,\n BatchLookupOptions,\n SearchOptions,\n SearchResponse,\n} from \"../types/common.js\";\nimport type { CvxData, CvxSearchParams } from \"../types/cvx.js\";\n\n/**\n * CVX (Vaccine Codes) API endpoint.\n */\nexport class CvxEndpoint {\n constructor(private readonly http: HttpClient) {}\n\n /**\n * Look up a single CVX code.\n *\n * @param cvxCode - CVX vaccine code\n * @param options - Response shape and include options\n * @returns CVX data\n *\n * @example\n * ```ts\n * const cvx = await client.cvx.lookup(\"208\");\n * console.log(cvx.data.short_description); // \"COVID-19, mRNA, LNP-S, PF, 30 mcg/0.3 mL dose\"\n * ```\n */\n async lookup(cvxCode: string, options?: LookupOptions): Promise<ApiResponse<CvxData>> {\n return this.http.get<ApiResponse<CvxData>>(`/v1/cvx/${encodeURIComponent(cvxCode)}`, options);\n }\n\n /**\n * Look up multiple CVX codes in a single request.\n *\n * @param cvxCodes - Array of CVX codes (max 500)\n * @param options - Response shape, include, and batch options\n * @returns Batch response with results for each code\n */\n async lookupMany(\n cvxCodes: string[],\n options?: BatchLookupOptions\n ): Promise<BatchResponse<CvxData>> {\n return this.http.post<BatchResponse<CvxData>>(\n \"/v1/cvx/_batch\",\n { codes: cvxCodes },\n options\n );\n }\n\n /**\n * Search for vaccine codes.\n *\n * @param params - Search parameters (q, status, vaccine_type, is_covid_vaccine)\n * @param options - Pagination and response shape options\n * @returns Search results with facets\n *\n * @example\n * ```ts\n * // Search for flu vaccines\n * const results = await client.cvx.search({ q: \"influenza\" });\n *\n * // Find all COVID-19 vaccines\n * const results = await client.cvx.search({\n * is_covid_vaccine: true,\n * status: \"active\"\n * });\n * ```\n */\n async search(\n params: CvxSearchParams,\n options?: SearchOptions\n ): Promise<SearchResponse<CvxData>> {\n return this.http.search<SearchResponse<CvxData>>(\"/v1/cvx/search\", {\n ...params,\n ...options,\n include: options?.include?.join(\",\"),\n });\n }\n}\n","import type { HttpClient } from \"../http.js\";\nimport type {\n ApiResponse,\n BatchResponse,\n LookupOptions,\n BatchLookupOptions,\n SearchOptions,\n SearchResponse,\n} from \"../types/common.js\";\nimport type { MvxData, MvxSearchParams } from \"../types/mvx.js\";\n\n/**\n * MVX (Vaccine Manufacturer Codes) API endpoint.\n */\nexport class MvxEndpoint {\n constructor(private readonly http: HttpClient) {}\n\n /**\n * Look up a single MVX code.\n *\n * @param mvxCode - MVX manufacturer code\n * @param options - Response shape and include options\n * @returns MVX data\n *\n * @example\n * ```ts\n * const mvx = await client.mvx.lookup(\"PFR\");\n * console.log(mvx.data.manufacturer_name); // \"Pfizer, Inc\"\n * ```\n */\n async lookup(mvxCode: string, options?: LookupOptions): Promise<ApiResponse<MvxData>> {\n return this.http.get<ApiResponse<MvxData>>(`/v1/mvx/${encodeURIComponent(mvxCode)}`, options);\n }\n\n /**\n * Look up multiple MVX codes in a single request.\n *\n * @param mvxCodes - Array of MVX codes (max 500)\n * @param options - Response shape, include, and batch options\n * @returns Batch response with results for each code\n */\n async lookupMany(\n mvxCodes: string[],\n options?: BatchLookupOptions\n ): Promise<BatchResponse<MvxData>> {\n return this.http.post<BatchResponse<MvxData>>(\n \"/v1/mvx/_batch\",\n { codes: mvxCodes },\n options\n );\n }\n\n /**\n * Search for vaccine manufacturers.\n *\n * @param params - Search parameters (q, status)\n * @param options - Pagination and response shape options\n * @returns Search results with facets\n *\n * @example\n * ```ts\n * // Search by name\n * const results = await client.mvx.search({ q: \"pfizer\" });\n *\n * // List all active manufacturers\n * const results = await client.mvx.search({ status: \"active\" });\n * ```\n */\n async search(\n params: MvxSearchParams,\n options?: SearchOptions\n ): Promise<SearchResponse<MvxData>> {\n return this.http.search<SearchResponse<MvxData>>(\"/v1/mvx/search\", {\n ...params,\n ...options,\n include: options?.include?.join(\",\"),\n });\n }\n}\n","import type { HttpClient } from \"../http.js\";\nimport type {\n ApiResponse,\n BatchResponse,\n LookupOptions,\n BatchLookupOptions,\n SearchOptions,\n SearchResponse,\n} from \"../types/common.js\";\nimport type { FdaLabelData, FdaLabelSearchParams } from \"../types/fda-labels.js\";\n\n/**\n * FDA Labels API endpoint.\n */\nexport class FdaLabelsEndpoint {\n constructor(private readonly http: HttpClient) {}\n\n /**\n * Look up FDA label by identifier (Set ID, NDC, or RxCUI).\n *\n * The API auto-detects the identifier type based on format.\n *\n * @param identifier - FDA SPL Set ID, NDC code, or RxCUI\n * @param options - Response shape and include options\n * @returns FDA Label data\n *\n * @example\n * ```ts\n * // By Set ID\n * const label = await client.fdaLabels.lookup(\"abc123-def456\");\n *\n * // By NDC\n * const label = await client.fdaLabels.lookup(\"0069-0151-01\");\n *\n * // By RxCUI\n * const label = await client.fdaLabels.lookup(\"404773\");\n * ```\n */\n async lookup(identifier: string, options?: LookupOptions): Promise<ApiResponse<FdaLabelData>> {\n return this.http.get<ApiResponse<FdaLabelData>>(`/v1/fda-label/${encodeURIComponent(identifier)}`, options);\n }\n\n /**\n * Look up multiple FDA labels by identifiers in a single request.\n *\n * Identifiers can be Set IDs, NDC codes, or RxCUIs (mixed).\n *\n * @param identifiers - Array of identifiers (max 500)\n * @param options - Response shape, include, and batch options\n * @returns Batch response with results for each identifier\n */\n async lookupMany(\n identifiers: string[],\n options?: BatchLookupOptions\n ): Promise<BatchResponse<FdaLabelData>> {\n return this.http.post<BatchResponse<FdaLabelData>>(\n \"/v1/fda-label/_batch\",\n { identifiers },\n options\n );\n }\n\n /**\n * Search for FDA drug labels.\n *\n * @param params - Search parameters (q, name, brand, substance, manufacturer, etc.)\n * @param options - Pagination and response shape options\n * @returns Search results with facets\n *\n * @example\n * ```ts\n * // Search by drug name\n * const results = await client.fdaLabels.search({ q: \"advil\" });\n *\n * // Search OTC pain relievers\n * const results = await client.fdaLabels.search({\n * substance: \"acetaminophen\",\n * product_type: \"otc\"\n * });\n *\n * // Search by manufacturer\n * const results = await client.fdaLabels.search({\n * manufacturer: \"pfizer\",\n * product_type: \"rx\"\n * });\n * ```\n */\n async search(\n params: FdaLabelSearchParams,\n options?: SearchOptions\n ): Promise<SearchResponse<FdaLabelData>> {\n return this.http.search<SearchResponse<FdaLabelData>>(\"/v1/fda-label/search\", {\n ...params,\n ...options,\n include: options?.include?.join(\",\"),\n });\n }\n}\n","import { HttpClient, TokenManager, type HttpClientConfig } from \"./http.js\";\nimport { NdcEndpoint } from \"./endpoints/ndc.js\";\nimport { NpiEndpoint } from \"./endpoints/npi.js\";\nimport { RxNormEndpoint } from \"./endpoints/rxnorm.js\";\nimport { LoincEndpoint } from \"./endpoints/loinc.js\";\nimport { Icd10Endpoint } from \"./endpoints/icd10.js\";\nimport { CvxEndpoint } from \"./endpoints/cvx.js\";\nimport { MvxEndpoint } from \"./endpoints/mvx.js\";\nimport { FdaLabelsEndpoint } from \"./endpoints/fda-labels.js\";\n\n/**\n * Base configuration options shared by all auth modes.\n */\ninterface FhirflyBaseConfig {\n /**\n * Base URL for the API.\n * @default \"https://api.fhirfly.io\"\n */\n baseUrl?: string;\n\n /**\n * Request timeout in milliseconds.\n * @default 30000\n */\n timeout?: number;\n\n /**\n * Maximum number of retry attempts for failed requests.\n * @default 3\n */\n maxRetries?: number;\n\n /**\n * Base delay between retries in milliseconds (exponential backoff).\n * @default 1000\n */\n retryDelay?: number;\n}\n\n/**\n * Configuration using an API key (simple credentials).\n */\nexport interface FhirflyApiKeyConfig extends FhirflyBaseConfig {\n /**\n * Your FHIRfly API key.\n * Get one at https://fhirfly.io/dashboard\n */\n apiKey: string;\n clientId?: never;\n clientSecret?: never;\n tokenUrl?: never;\n scopes?: never;\n}\n\n/**\n * Configuration using OAuth2 client credentials (secure credentials).\n */\nexport interface FhirflyOAuthConfig extends FhirflyBaseConfig {\n /**\n * OAuth2 client ID from your secure credential.\n */\n clientId: string;\n\n /**\n * OAuth2 client secret from your secure credential.\n */\n clientSecret: string;\n\n /**\n * OAuth2 token endpoint URL.\n * @default \"{baseUrl}/oauth2/token\"\n */\n tokenUrl?: string;\n\n /**\n * OAuth2 scopes to request.\n */\n scopes?: string[];\n\n apiKey?: never;\n}\n\n/**\n * Configuration options for the FHIRfly client.\n * Provide either `apiKey` OR `clientId`+`clientSecret`, not both.\n */\nexport type FhirflyConfig = FhirflyApiKeyConfig | FhirflyOAuthConfig;\n\n/**\n * FHIRfly API client.\n *\n * Provides access to healthcare reference data including drug codes (NDC, RxNorm),\n * provider identifiers (NPI), lab codes (LOINC), diagnosis codes (ICD-10),\n * vaccine codes (CVX, MVX), and FDA drug labels.\n *\n * @example\n * ```ts\n * import { Fhirfly } from \"@fhirfly/sdk\";\n *\n * // Option A: API key (simple)\n * const client = new Fhirfly({ apiKey: \"ffly_sk_live_...\" });\n *\n * // Option B: Client credentials (secure)\n * const client = new Fhirfly({\n * clientId: \"ffly_client_...\",\n * clientSecret: \"ffly_secret_...\",\n * });\n *\n * // Look up a drug by NDC\n * const ndc = await client.ndc.lookup(\"0069-0151-01\");\n * console.log(ndc.data.product_name); // \"Lipitor\"\n * ```\n */\nexport class Fhirfly {\n private readonly http: HttpClient;\n\n /**\n * NDC (National Drug Code) lookups.\n */\n readonly ndc: NdcEndpoint;\n\n /**\n * NPI (National Provider Identifier) lookups.\n */\n readonly npi: NpiEndpoint;\n\n /**\n * RxNorm drug terminology lookups.\n */\n readonly rxnorm: RxNormEndpoint;\n\n /**\n * LOINC laboratory and clinical observation code lookups.\n */\n readonly loinc: LoincEndpoint;\n\n /**\n * ICD-10 diagnosis and procedure code lookups.\n */\n readonly icd10: Icd10Endpoint;\n\n /**\n * CVX vaccine code lookups.\n */\n readonly cvx: CvxEndpoint;\n\n /**\n * MVX vaccine manufacturer code lookups.\n */\n readonly mvx: MvxEndpoint;\n\n /**\n * FDA drug label lookups.\n */\n readonly fdaLabels: FdaLabelsEndpoint;\n\n /**\n * Create a new FHIRfly client.\n *\n * @param config - Client configuration (API key or OAuth2 client credentials)\n * @throws {Error} If neither apiKey nor clientId+clientSecret is provided\n */\n constructor(config: FhirflyConfig) {\n const baseUrl = config.baseUrl ?? \"https://api.fhirfly.io\";\n\n let httpConfig: HttpClientConfig;\n\n if (\"apiKey\" in config && config.apiKey) {\n httpConfig = {\n baseUrl,\n auth: { type: \"api-key\", apiKey: config.apiKey },\n timeout: config.timeout,\n maxRetries: config.maxRetries,\n retryDelay: config.retryDelay,\n };\n } else if (\"clientId\" in config && config.clientId && config.clientSecret) {\n const tokenManager = new TokenManager({\n clientId: config.clientId,\n clientSecret: config.clientSecret,\n tokenUrl: config.tokenUrl ?? `${baseUrl}/oauth2/token`,\n scopes: config.scopes,\n });\n httpConfig = {\n baseUrl,\n auth: { type: \"oauth\", tokenManager },\n timeout: config.timeout,\n maxRetries: config.maxRetries,\n retryDelay: config.retryDelay,\n };\n } else {\n throw new Error(\n \"FHIRfly requires either an apiKey or clientId+clientSecret. Get credentials at https://fhirfly.io/dashboard\"\n );\n }\n\n this.http = new HttpClient(httpConfig);\n\n // Initialize endpoints\n this.ndc = new NdcEndpoint(this.http);\n this.npi = new NpiEndpoint(this.http);\n this.rxnorm = new RxNormEndpoint(this.http);\n this.loinc = new LoincEndpoint(this.http);\n this.icd10 = new Icd10Endpoint(this.http);\n this.cvx = new CvxEndpoint(this.http);\n this.mvx = new MvxEndpoint(this.http);\n this.fdaLabels = new FdaLabelsEndpoint(this.http);\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/errors.ts","../src/http.ts","../src/endpoints/ndc.ts","../src/endpoints/npi.ts","../src/endpoints/rxnorm.ts","../src/endpoints/loinc.ts","../src/endpoints/icd10.ts","../src/endpoints/cvx.ts","../src/endpoints/mvx.ts","../src/endpoints/fda-labels.ts","../src/endpoints/connectivity.ts","../src/endpoints/snomed.ts","../src/client.ts"],"names":[],"mappings":";;;AAGO,IAAM,YAAA,GAAN,MAAM,aAAA,SAAqB,KAAA,CAAM;AAAA,EACtC,YAAY,OAAA,EAAiB;AAC3B,IAAA,KAAA,CAAM,OAAO,CAAA;AACb,IAAA,IAAA,CAAK,IAAA,GAAO,cAAA;AACZ,IAAA,MAAA,CAAO,cAAA,CAAe,IAAA,EAAM,aAAA,CAAa,SAAS,CAAA;AAAA,EACpD;AACF;AAKO,IAAM,QAAA,GAAN,MAAM,SAAA,SAAiB,YAAA,CAAa;AAAA,EAChC,UAAA;AAAA,EACA,IAAA;AAAA,EACA,OAAA;AAAA,EAET,WAAA,CACE,OAAA,EACA,UAAA,EACA,IAAA,EACA,OAAA,EACA;AACA,IAAA,KAAA,CAAM,OAAO,CAAA;AACb,IAAA,IAAA,CAAK,IAAA,GAAO,UAAA;AACZ,IAAA,IAAA,CAAK,UAAA,GAAa,UAAA;AAClB,IAA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AK,GAAA,GAAM,IAAI,WAAA,CAAY,IAAA,CAAK,IAAI,CAAA;AACpC,IAAA,IAAA,CAAK,GAAA,GAAM,IAAI,WAAA,CAAY,IAAA,CAAK,IAAI,CAAA;AACpC,IAAA,IAAA,CAAK,SAAA,GAAY,IAAI,iBAAA,CAAkB,IAAA,CAAK,IAAI,CAAA;AAChD,IAAA,IAAA,CAAK,YAAA,GAAe,IAAI,oBAAA,CAAqB,IAAA,CAAK,IAAI,CAAA;AACtD,IAAA,IAAA,CAAK,MAAA,GAAS,IAAI,cAAA,CAAe,IAAA,CAAK,IAAI,CAAA;AAAA,EAC5C;AACF","file":"index.cjs","sourcesContent":["/**\n * Base error class for all FHIRfly SDK errors.\n */\nexport class FhirflyError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"FhirflyError\";\n Object.setPrototypeOf(this, FhirflyError.prototype);\n }\n}\n\n/**\n * Error thrown when the API returns an error response.\n */\nexport class ApiError extends FhirflyError {\n readonly statusCode: number;\n readonly code?: string;\n readonly details?: unknown;\n\n constructor(\n message: string,\n statusCode: number,\n code?: string,\n details?: unknown\n ) {\n super(message);\n this.name = \"ApiError\";\n this.statusCode = statusCode;\n this.code = code;\n this.details = details;\n Object.setPrototypeOf(this, ApiError.prototype);\n }\n}\n\n/**\n * Error thrown when authentication fails (401).\n */\nexport class AuthenticationError extends ApiError {\n constructor(message = \"Authentication failed. Check your API key.\") {\n super(message, 401, \"AUTHENTICATION_ERROR\");\n this.name = \"AuthenticationError\";\n Object.setPrototypeOf(this, AuthenticationError.prototype);\n }\n}\n\n/**\n * Error thrown when a resource is not found (404).\n */\nexport class NotFoundError extends ApiError {\n readonly code_type: string;\n readonly code_value: string;\n\n constructor(codeType: string, codeValue: string) {\n super(`${codeType} not found: ${codeValue}`, 404, \"NOT_FOUND\");\n this.name = \"NotFoundError\";\n this.code_type = codeType;\n this.code_value = codeValue;\n Object.setPrototypeOf(this, NotFoundError.prototype);\n }\n}\n\n/**\n * Error thrown when the request is invalid (400).\n */\nexport class ValidationError extends ApiError {\n readonly field?: string;\n\n constructor(message: string, field?: string) {\n super(message, 400, \"VALIDATION_ERROR\");\n this.name = \"ValidationError\";\n this.field = field;\n Object.setPrototypeOf(this, ValidationError.prototype);\n }\n}\n\n/**\n * Error thrown when rate limited (429).\n */\nexport class RateLimitError extends ApiError {\n readonly retryAfter?: number;\n readonly limit?: number;\n readonly remaining?: number;\n readonly reset?: Date;\n\n constructor(\n message = \"Rate limit exceeded\",\n retryAfter?: number,\n limit?: number,\n remaining?: number,\n reset?: Date\n ) {\n super(message, 429, \"RATE_LIMIT_EXCEEDED\");\n this.name = \"RateLimitError\";\n this.retryAfter = retryAfter;\n this.limit = limit;\n this.remaining = remaining;\n this.reset = reset;\n Object.setPrototypeOf(this, RateLimitError.prototype);\n }\n}\n\n/**\n * Error thrown when quota is exceeded (429 with quota context).\n */\nexport class QuotaExceededError extends ApiError {\n readonly quotaLimit?: number;\n readonly quotaUsed?: number;\n readonly quotaResetDate?: Date;\n\n constructor(\n message = \"Monthly quota exceeded\",\n quotaLimit?: number,\n quotaUsed?: number,\n quotaResetDate?: Date\n ) {\n super(message, 429, \"QUOTA_EXCEEDED\");\n this.name = \"QuotaExceededError\";\n this.quotaLimit = quotaLimit;\n this.quotaUsed = quotaUsed;\n this.quotaResetDate = quotaResetDate;\n Object.setPrototypeOf(this, QuotaExceededError.prototype);\n }\n}\n\n/**\n * Error thrown when the server returns a 5xx error.\n */\nexport class ServerError extends ApiError {\n constructor(message = \"Server error\", statusCode = 500) {\n super(message, statusCode, \"SERVER_ERROR\");\n this.name = \"ServerError\";\n Object.setPrototypeOf(this, ServerError.prototype);\n }\n}\n\n/**\n * Error thrown when a network error occurs.\n */\nexport class NetworkError extends FhirflyError {\n readonly cause?: Error;\n\n constructor(message = \"Network error\", cause?: Error) {\n super(message);\n this.name = \"NetworkError\";\n this.cause = cause;\n Object.setPrototypeOf(this, NetworkError.prototype);\n }\n}\n\n/**\n * Error thrown when a request times out.\n */\nexport class TimeoutError extends FhirflyError {\n readonly timeoutMs: number;\n\n constructor(timeoutMs: number) {\n super(`Request timed out after ${timeoutMs}ms`);\n this.name = \"TimeoutError\";\n this.timeoutMs = timeoutMs;\n Object.setPrototypeOf(this, TimeoutError.prototype);\n }\n}\n","import {\n ApiError,\n AuthenticationError,\n NetworkError,\n NotFoundError,\n QuotaExceededError,\n RateLimitError,\n ServerError,\n TimeoutError,\n ValidationError,\n} from \"./errors.js\";\nimport type { LookupOptions } from \"./types/common.js\";\n\n/**\n * OAuth2 token response from the token endpoint.\n */\ninterface TokenResponse {\n access_token: string;\n token_type: string;\n expires_in: number;\n scope?: string;\n}\n\n/**\n * OAuth2 client credentials configuration.\n */\nexport interface OAuthCredentials {\n clientId: string;\n clientSecret: string;\n tokenUrl: string;\n scopes?: string[];\n}\n\n/**\n * Manages OAuth2 access tokens with automatic refresh.\n */\nexport class TokenManager {\n private readonly credentials: OAuthCredentials;\n private accessToken: string | null = null;\n private expiresAt = 0;\n private refreshPromise: Promise<string> | null = null;\n\n constructor(credentials: OAuthCredentials) {\n this.credentials = credentials;\n }\n\n /**\n * Get a valid access token, refreshing if needed.\n * Deduplicates concurrent refresh calls.\n */\n async getToken(): Promise<string> {\n if (this.accessToken && Date.now() < this.expiresAt) {\n return this.accessToken;\n }\n if (this.refreshPromise) {\n return this.refreshPromise;\n }\n this.refreshPromise = this.fetchToken();\n try {\n return await this.refreshPromise;\n } finally {\n this.refreshPromise = null;\n }\n }\n\n /**\n * Invalidate the cached token (e.g., after a 401 response).\n */\n invalidate(): void {\n this.accessToken = null;\n this.expiresAt = 0;\n }\n\n private async fetchToken(): Promise<string> {\n const body = new URLSearchParams({\n grant_type: \"client_credentials\",\n client_id: this.credentials.clientId,\n client_secret: this.credentials.clientSecret,\n });\n if (this.credentials.scopes?.length) {\n body.set(\"scope\", this.credentials.scopes.join(\" \"));\n }\n\n const response = await fetch(this.credentials.tokenUrl, {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/x-www-form-urlencoded\" },\n body: body.toString(),\n });\n\n if (!response.ok) {\n const text = await response.text().catch(() => \"\");\n throw new AuthenticationError(\n `OAuth2 token exchange failed (${response.status}): ${text}`\n );\n }\n\n const data = (await response.json()) as TokenResponse;\n this.accessToken = data.access_token;\n // Refresh 60s before expiry\n this.expiresAt = Date.now() + (data.expires_in - 60) * 1000;\n return this.accessToken;\n }\n}\n\n/**\n * Authentication mode for the HTTP client.\n */\ntype AuthMode =\n | { type: \"api-key\"; apiKey: string }\n | { type: \"oauth\"; tokenManager: TokenManager };\n\n/**\n * HTTP client configuration.\n */\nexport interface HttpClientConfig {\n baseUrl: string;\n auth: AuthMode;\n timeout?: number;\n maxRetries?: number;\n retryDelay?: number;\n userAgent?: string;\n}\n\n/**\n * HTTP response from the API.\n */\ninterface HttpResponse<T> {\n data: T;\n status: number;\n headers: Headers;\n}\n\n/**\n * Internal HTTP client for making API requests.\n */\nexport class HttpClient {\n private readonly config: Required<Omit<HttpClientConfig, \"auth\">> & { auth: AuthMode };\n\n constructor(config: HttpClientConfig) {\n this.config = {\n baseUrl: config.baseUrl,\n auth: config.auth,\n timeout: config.timeout ?? 30000,\n maxRetries: config.maxRetries ?? 3,\n retryDelay: config.retryDelay ?? 1000,\n userAgent: config.userAgent ?? `@fhirfly/sdk/0.1.0 Node.js/${process.version}`,\n };\n }\n\n /**\n * Build query string from options.\n */\n private buildQueryString(options?: LookupOptions): string {\n if (!options) return \"\";\n\n const params = new URLSearchParams();\n\n if (options.shape) {\n params.set(\"shape\", options.shape);\n }\n\n if (options.include?.length) {\n params.set(\"include\", options.include.join(\",\"));\n }\n\n const queryString = params.toString();\n return queryString ? `?${queryString}` : \"\";\n }\n\n /**\n * Build query string from search params object.\n */\n buildSearchQueryString(params: Record<string, unknown>): string {\n const searchParams = new URLSearchParams();\n\n for (const [key, value] of Object.entries(params)) {\n if (value === undefined || value === null) continue;\n\n if (typeof value === \"boolean\") {\n searchParams.set(key, value.toString());\n } else if (typeof value === \"number\") {\n searchParams.set(key, value.toString());\n } else if (typeof value === \"string\" && value.length > 0) {\n searchParams.set(key, value);\n } else if (Array.isArray(value) && value.length > 0) {\n searchParams.set(key, value.join(\",\"));\n }\n }\n\n const queryString = searchParams.toString();\n return queryString ? `?${queryString}` : \"\";\n }\n\n /**\n * Parse error response from API.\n */\n private async parseErrorResponse(\n response: Response,\n endpoint: string\n ): Promise<never> {\n const status = response.status;\n let body: { message?: string; code?: string; error?: string; details?: unknown } = {};\n\n try {\n body = await response.json() as typeof body;\n } catch {\n // Response body is not JSON\n }\n\n const message = body.message || body.error || response.statusText;\n\n // Handle specific status codes\n switch (status) {\n case 401:\n throw new AuthenticationError(message);\n\n case 404: {\n // Extract code type and value from endpoint\n const match = endpoint.match(/\\/v1\\/(\\w+)\\/(.+)/);\n if (match) {\n throw new NotFoundError(match[1]!.toUpperCase(), match[2]!);\n }\n throw new NotFoundError(\"Resource\", endpoint);\n }\n\n case 400:\n throw new ValidationError(message);\n\n case 429: {\n const retryAfter = response.headers.get(\"retry-after\");\n const limit = response.headers.get(\"x-ratelimit-limit\");\n const remaining = response.headers.get(\"x-ratelimit-remaining\");\n const reset = response.headers.get(\"x-ratelimit-reset\");\n\n // Check if it's a quota error vs rate limit\n if (body.code === \"QUOTA_EXCEEDED\") {\n throw new QuotaExceededError(message);\n }\n\n throw new RateLimitError(\n message,\n retryAfter ? parseInt(retryAfter, 10) : undefined,\n limit ? parseInt(limit, 10) : undefined,\n remaining ? parseInt(remaining, 10) : undefined,\n reset ? new Date(parseInt(reset, 10) * 1000) : undefined\n );\n }\n\n default:\n if (status >= 500) {\n throw new ServerError(message, status);\n }\n throw new ApiError(message, status, body.code, body.details);\n }\n }\n\n /**\n * Sleep for a given number of milliseconds.\n */\n private sleep(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n }\n\n /**\n * Get auth headers for the current request.\n */\n private async getAuthHeaders(): Promise<Record<string, string>> {\n if (this.config.auth.type === \"api-key\") {\n return { \"x-api-key\": this.config.auth.apiKey };\n }\n const token = await this.config.auth.tokenManager.getToken();\n return { \"Authorization\": `Bearer ${token}` };\n }\n\n /**\n * Make an HTTP request with retries.\n */\n private async request<T>(\n method: \"GET\" | \"POST\",\n endpoint: string,\n body?: unknown,\n isRetryAfter401 = false\n ): Promise<HttpResponse<T>> {\n const url = `${this.config.baseUrl}${endpoint}`;\n let lastError: Error | undefined;\n\n for (let attempt = 0; attempt <= this.config.maxRetries; attempt++) {\n try {\n const controller = new AbortController();\n const timeoutId = setTimeout(\n () => controller.abort(),\n this.config.timeout\n );\n\n const authHeaders = await this.getAuthHeaders();\n\n const response = await fetch(url, {\n method,\n headers: {\n ...authHeaders,\n \"Content-Type\": \"application/json\",\n \"User-Agent\": this.config.userAgent,\n \"Accept\": \"application/json\",\n },\n body: body ? JSON.stringify(body) : undefined,\n signal: controller.signal,\n });\n\n clearTimeout(timeoutId);\n\n if (!response.ok) {\n // On 401 with OAuth, invalidate token and retry once\n if (\n response.status === 401 &&\n this.config.auth.type === \"oauth\" &&\n !isRetryAfter401\n ) {\n this.config.auth.tokenManager.invalidate();\n return this.request<T>(method, endpoint, body, true);\n }\n\n // Don't retry client errors (except rate limits)\n if (response.status < 500 && response.status !== 429) {\n await this.parseErrorResponse(response, endpoint);\n }\n\n // For rate limits, check retry-after header\n if (response.status === 429) {\n const retryAfter = response.headers.get(\"retry-after\");\n if (retryAfter && attempt < this.config.maxRetries) {\n await this.sleep(parseInt(retryAfter, 10) * 1000);\n continue;\n }\n await this.parseErrorResponse(response, endpoint);\n }\n\n // Retry server errors\n if (attempt < this.config.maxRetries) {\n await this.sleep(this.config.retryDelay * Math.pow(2, attempt));\n continue;\n }\n\n await this.parseErrorResponse(response, endpoint);\n }\n\n const data = await response.json() as T;\n return { data, status: response.status, headers: response.headers };\n } catch (error) {\n if (error instanceof ApiError) {\n throw error;\n }\n\n if (error instanceof Error) {\n if (error.name === \"AbortError\") {\n throw new TimeoutError(this.config.timeout);\n }\n\n lastError = error;\n\n // Retry on network errors\n if (attempt < this.config.maxRetries) {\n await this.sleep(this.config.retryDelay * Math.pow(2, attempt));\n continue;\n }\n }\n\n throw new NetworkError(\n lastError?.message || \"Unknown network error\",\n lastError\n );\n }\n }\n\n throw new NetworkError(\n lastError?.message || \"Request failed after retries\",\n lastError\n );\n }\n\n /**\n * Make a GET request.\n */\n async get<T>(endpoint: string, options?: LookupOptions): Promise<T> {\n const queryString = this.buildQueryString(options);\n const response = await this.request<T>(\"GET\", `${endpoint}${queryString}`);\n return response.data;\n }\n\n /**\n * Make a POST request.\n */\n async post<T>(endpoint: string, body: unknown, options?: LookupOptions): Promise<T> {\n const queryString = this.buildQueryString(options);\n const response = await this.request<T>(\"POST\", `${endpoint}${queryString}`, body);\n return response.data;\n }\n\n /**\n * Make a GET request with search parameters.\n */\n async search<T>(endpoint: string, params: Record<string, unknown>): Promise<T> {\n const queryString = this.buildSearchQueryString(params);\n const response = await this.request<T>(\"GET\", `${endpoint}${queryString}`);\n return response.data;\n }\n}\n","import type { HttpClient } from \"../http.js\";\nimport type {\n ApiResponse,\n BatchResponse,\n LookupOptions,\n BatchLookupOptions,\n SearchOptions,\n SearchResponse,\n} from \"../types/common.js\";\nimport type { NdcData, NdcSearchParams } from \"../types/ndc.js\";\n\n/**\n * NDC (National Drug Code) API endpoint.\n */\nexport class NdcEndpoint {\n constructor(private readonly http: HttpClient) {}\n\n /**\n * Look up a single NDC code.\n *\n * @param code - NDC code (10-digit, 11-digit, or hyphenated format)\n * @param options - Response shape and include options\n * @returns NDC data\n *\n * @example\n * ```ts\n * const ndc = await client.ndc.lookup(\"0069-0151-01\");\n * console.log(ndc.data.product_name); // \"Lipitor\"\n * ```\n */\n async lookup(code: string, options?: LookupOptions): Promise<ApiResponse<NdcData>> {\n return this.http.get<ApiResponse<NdcData>>(`/v1/ndc/${encodeURIComponent(code)}`, options);\n }\n\n /**\n * Look up multiple NDC codes in a single request.\n *\n * @param codes - Array of NDC codes (max 500)\n * @param options - Response shape, include, and batch options\n * @returns Batch response with results for each code\n *\n * @example\n * ```ts\n * const results = await client.ndc.lookupMany([\n * \"0069-0151-01\",\n * \"0069-0151-02\",\n * \"invalid-code\"\n * ]);\n *\n * for (const item of results.results) {\n * if (item.found) {\n * console.log(item.data.product_name);\n * } else {\n * console.log(`Not found: ${item.code}`);\n * }\n * }\n * ```\n */\n async lookupMany(\n codes: string[],\n options?: BatchLookupOptions\n ): Promise<BatchResponse<NdcData>> {\n return this.http.post<BatchResponse<NdcData>>(\n \"/v1/ndc/_batch\",\n { codes },\n options\n );\n }\n\n /**\n * Search for NDC products.\n *\n * @param params - Search parameters (q, name, brand, ingredient, etc.)\n * @param options - Pagination and response shape options\n * @returns Search results with facets\n *\n * @example\n * ```ts\n * // Search by drug name\n * const results = await client.ndc.search({ q: \"advil\" });\n *\n * // Search with filters\n * const results = await client.ndc.search({\n * ingredient: \"ibuprofen\",\n * dosage_form: \"TABLET\",\n * product_type: \"otc\"\n * });\n *\n * console.log(`Found ${results.total} products`);\n * for (const item of results.items) {\n * console.log(item.product_name);\n * }\n * ```\n */\n async search(\n params: NdcSearchParams,\n options?: SearchOptions\n ): Promise<SearchResponse<NdcData>> {\n return this.http.search<SearchResponse<NdcData>>(\"/v1/ndc/search\", {\n ...params,\n ...options,\n include: options?.include?.join(\",\"),\n });\n }\n}\n","import type { HttpClient } from \"../http.js\";\nimport type {\n ApiResponse,\n BatchResponse,\n LookupOptions,\n BatchLookupOptions,\n SearchOptions,\n SearchResponse,\n} from \"../types/common.js\";\nimport type { NpiData, NpiSearchParams } from \"../types/npi.js\";\n\n/**\n * NPI (National Provider Identifier) API endpoint.\n */\nexport class NpiEndpoint {\n constructor(private readonly http: HttpClient) {}\n\n /**\n * Look up a single NPI.\n *\n * @param npi - 10-digit NPI number\n * @param options - Response shape and include options\n * @returns NPI data\n *\n * @example\n * ```ts\n * const npi = await client.npi.lookup(\"1234567890\");\n * console.log(npi.data.name);\n * ```\n */\n async lookup(npi: string, options?: LookupOptions): Promise<ApiResponse<NpiData>> {\n return this.http.get<ApiResponse<NpiData>>(`/v1/npi/${encodeURIComponent(npi)}`, options);\n }\n\n /**\n * Look up multiple NPIs in a single request.\n *\n * @param npis - Array of 10-digit NPI numbers (max 500)\n * @param options - Response shape, include, and batch options\n * @returns Batch response with results for each NPI\n *\n * @example\n * ```ts\n * const results = await client.npi.lookupMany([\n * \"1234567890\",\n * \"0987654321\"\n * ]);\n * ```\n */\n async lookupMany(\n npis: string[],\n options?: BatchLookupOptions\n ): Promise<BatchResponse<NpiData>> {\n return this.http.post<BatchResponse<NpiData>>(\n \"/v1/npi/_batch\",\n { npis },\n options\n );\n }\n\n /**\n * Search for healthcare providers.\n *\n * @param params - Search parameters (q, name, specialty, state, etc.)\n * @param options - Pagination and response shape options\n * @returns Search results with facets\n *\n * @example\n * ```ts\n * // Search by name\n * const results = await client.npi.search({ q: \"smith\" });\n *\n * // Search with filters\n * const results = await client.npi.search({\n * specialty: \"cardiology\",\n * state: \"CA\",\n * entity_type: \"individual\"\n * });\n *\n * console.log(`Found ${results.total} providers`);\n * ```\n */\n async search(\n params: NpiSearchParams,\n options?: SearchOptions\n ): Promise<SearchResponse<NpiData>> {\n return this.http.search<SearchResponse<NpiData>>(\"/v1/npi/search\", {\n ...params,\n ...options,\n include: options?.include?.join(\",\"),\n });\n }\n}\n","import type { HttpClient } from \"../http.js\";\nimport type {\n ApiResponse,\n BatchResponse,\n LookupOptions,\n BatchLookupOptions,\n SearchOptions,\n SearchResponse,\n} from \"../types/common.js\";\nimport type { RxNormData, RxNormSearchParams } from \"../types/rxnorm.js\";\n\n/**\n * RxNorm API endpoint.\n */\nexport class RxNormEndpoint {\n constructor(private readonly http: HttpClient) {}\n\n /**\n * Look up a single RxCUI.\n *\n * @param rxcui - RxNorm Concept Unique Identifier\n * @param options - Response shape and include options\n * @returns RxNorm data\n *\n * @example\n * ```ts\n * const rx = await client.rxnorm.lookup(\"213169\");\n * console.log(rx.data.name); // \"atorvastatin 10 MG Oral Tablet\"\n * ```\n */\n async lookup(rxcui: string, options?: LookupOptions): Promise<ApiResponse<RxNormData>> {\n return this.http.get<ApiResponse<RxNormData>>(`/v1/rxnorm/${encodeURIComponent(rxcui)}`, options);\n }\n\n /**\n * Look up multiple RxCUIs in a single request.\n *\n * @param rxcuis - Array of RxCUIs (max 500)\n * @param options - Response shape, include, and batch options\n * @returns Batch response with results for each RxCUI\n */\n async lookupMany(\n rxcuis: string[],\n options?: BatchLookupOptions\n ): Promise<BatchResponse<RxNormData>> {\n return this.http.post<BatchResponse<RxNormData>>(\n \"/v1/rxnorm/_batch\",\n { rxcuis },\n options\n );\n }\n\n /**\n * Search for drugs in RxNorm.\n *\n * @param params - Search parameters (q, name, ingredient, brand, etc.)\n * @param options - Pagination and response shape options\n * @returns Search results with facets\n *\n * @example\n * ```ts\n * // Search by drug name\n * const results = await client.rxnorm.search({ q: \"lipitor\" });\n *\n * // Search prescribable drugs by ingredient\n * const results = await client.rxnorm.search({\n * ingredient: \"metformin\",\n * is_prescribable: true\n * });\n * ```\n */\n async search(\n params: RxNormSearchParams,\n options?: SearchOptions\n ): Promise<SearchResponse<RxNormData>> {\n return this.http.search<SearchResponse<RxNormData>>(\"/v1/rxnorm/search\", {\n ...params,\n ...options,\n include: options?.include?.join(\",\"),\n });\n }\n}\n","import type { HttpClient } from \"../http.js\";\nimport type {\n ApiResponse,\n BatchResponse,\n LookupOptions,\n BatchLookupOptions,\n SearchOptions,\n SearchResponse,\n} from \"../types/common.js\";\nimport type { LoincData, LoincSearchParams } from \"../types/loinc.js\";\n\n/**\n * LOINC API endpoint.\n */\nexport class LoincEndpoint {\n constructor(private readonly http: HttpClient) {}\n\n /**\n * Look up a single LOINC code.\n *\n * @param loincNum - LOINC number (e.g., \"2345-7\")\n * @param options - Response shape and include options\n * @returns LOINC data\n *\n * @example\n * ```ts\n * const loinc = await client.loinc.lookup(\"2345-7\");\n * console.log(loinc.data.long_common_name); // \"Glucose [Mass/volume] in Serum or Plasma\"\n * ```\n */\n async lookup(loincNum: string, options?: LookupOptions): Promise<ApiResponse<LoincData>> {\n return this.http.get<ApiResponse<LoincData>>(`/v1/loinc/${encodeURIComponent(loincNum)}`, options);\n }\n\n /**\n * Look up multiple LOINC codes in a single request.\n *\n * @param loincNums - Array of LOINC numbers (max 500)\n * @param options - Response shape, include, and batch options\n * @returns Batch response with results for each LOINC\n */\n async lookupMany(\n loincNums: string[],\n options?: BatchLookupOptions\n ): Promise<BatchResponse<LoincData>> {\n return this.http.post<BatchResponse<LoincData>>(\n \"/v1/loinc/_batch\",\n { codes: loincNums },\n options\n );\n }\n\n /**\n * Search for LOINC codes.\n *\n * @param params - Search parameters (q, component, class, system, etc.)\n * @param options - Pagination and response shape options\n * @returns Search results with facets\n *\n * @example\n * ```ts\n * // Search by term\n * const results = await client.loinc.search({ q: \"glucose\" });\n *\n * // Search blood chemistry tests\n * const results = await client.loinc.search({\n * class: \"CHEM\",\n * system: \"Bld\",\n * scale: \"Qn\"\n * });\n * ```\n */\n async search(\n params: LoincSearchParams,\n options?: SearchOptions\n ): Promise<SearchResponse<LoincData>> {\n return this.http.search<SearchResponse<LoincData>>(\"/v1/loinc/search\", {\n ...params,\n ...options,\n include: options?.include?.join(\",\"),\n });\n }\n}\n","import type { HttpClient } from \"../http.js\";\nimport type {\n ApiResponse,\n BatchResponse,\n LookupOptions,\n BatchLookupOptions,\n SearchOptions,\n SearchResponse,\n} from \"../types/common.js\";\nimport type { Icd10Data, Icd10SearchParams } from \"../types/icd10.js\";\n\n/**\n * ICD-10 API endpoint.\n */\nexport class Icd10Endpoint {\n constructor(private readonly http: HttpClient) {}\n\n /**\n * Look up a single ICD-10 code (CM or PCS).\n *\n * The API auto-detects whether the code is CM (diagnoses) or PCS (procedures)\n * based on the code format.\n *\n * @param code - ICD-10 code (e.g., \"E11.9\" for CM, \"02HA0QZ\" for PCS)\n * @param options - Response shape and include options\n * @returns ICD-10 data\n *\n * @example\n * ```ts\n * // Diagnosis code (CM)\n * const diagnosis = await client.icd10.lookup(\"E11.9\");\n * console.log(diagnosis.data.description); // \"Type 2 diabetes mellitus without complications\"\n *\n * // Procedure code (PCS)\n * const procedure = await client.icd10.lookup(\"02HA0QZ\");\n * console.log(procedure.data.description);\n * ```\n */\n async lookup(code: string, options?: LookupOptions): Promise<ApiResponse<Icd10Data>> {\n return this.http.get<ApiResponse<Icd10Data>>(`/v1/icd10/${encodeURIComponent(code)}`, options);\n }\n\n /**\n * Look up multiple ICD-10 codes in a single request.\n *\n * Codes can be a mix of CM (diagnoses) and PCS (procedures).\n *\n * @param codes - Array of ICD-10 codes (max 500)\n * @param options - Response shape, include, and batch options\n * @returns Batch response with results for each code\n */\n async lookupMany(\n codes: string[],\n options?: BatchLookupOptions\n ): Promise<BatchResponse<Icd10Data>> {\n return this.http.post<BatchResponse<Icd10Data>>(\n \"/v1/icd10/_batch\",\n { codes },\n options\n );\n }\n\n /**\n * Search for ICD-10 codes (both CM and PCS).\n *\n * @param params - Search parameters (q, code_system, chapter, billable, etc.)\n * @param options - Pagination and response shape options\n * @returns Search results with facets\n *\n * @example\n * ```ts\n * // Search diagnosis codes\n * const results = await client.icd10.search({\n * q: \"diabetes\",\n * code_system: \"CM\",\n * billable: true\n * });\n *\n * // Search procedure codes\n * const results = await client.icd10.search({\n * q: \"bypass\",\n * code_system: \"PCS\"\n * });\n * ```\n */\n async search(\n params: Icd10SearchParams,\n options?: SearchOptions\n ): Promise<SearchResponse<Icd10Data>> {\n return this.http.search<SearchResponse<Icd10Data>>(\"/v1/icd10/search\", {\n ...params,\n ...options,\n include: options?.include?.join(\",\"),\n });\n }\n}\n","import type { HttpClient } from \"../http.js\";\nimport type {\n ApiResponse,\n BatchResponse,\n LookupOptions,\n BatchLookupOptions,\n SearchOptions,\n SearchResponse,\n} from \"../types/common.js\";\nimport type { CvxData, CvxSearchParams } from \"../types/cvx.js\";\n\n/**\n * CVX (Vaccine Codes) API endpoint.\n */\nexport class CvxEndpoint {\n constructor(private readonly http: HttpClient) {}\n\n /**\n * Look up a single CVX code.\n *\n * @param cvxCode - CVX vaccine code\n * @param options - Response shape and include options\n * @returns CVX data\n *\n * @example\n * ```ts\n * const cvx = await client.cvx.lookup(\"208\");\n * console.log(cvx.data.short_description); // \"COVID-19, mRNA, LNP-S, PF, 30 mcg/0.3 mL dose\"\n * ```\n */\n async lookup(cvxCode: string, options?: LookupOptions): Promise<ApiResponse<CvxData>> {\n return this.http.get<ApiResponse<CvxData>>(`/v1/cvx/${encodeURIComponent(cvxCode)}`, options);\n }\n\n /**\n * Look up multiple CVX codes in a single request.\n *\n * @param cvxCodes - Array of CVX codes (max 500)\n * @param options - Response shape, include, and batch options\n * @returns Batch response with results for each code\n */\n async lookupMany(\n cvxCodes: string[],\n options?: BatchLookupOptions\n ): Promise<BatchResponse<CvxData>> {\n return this.http.post<BatchResponse<CvxData>>(\n \"/v1/cvx/_batch\",\n { codes: cvxCodes },\n options\n );\n }\n\n /**\n * Search for vaccine codes.\n *\n * @param params - Search parameters (q, status, vaccine_type, is_covid_vaccine)\n * @param options - Pagination and response shape options\n * @returns Search results with facets\n *\n * @example\n * ```ts\n * // Search for flu vaccines\n * const results = await client.cvx.search({ q: \"influenza\" });\n *\n * // Find all COVID-19 vaccines\n * const results = await client.cvx.search({\n * is_covid_vaccine: true,\n * status: \"active\"\n * });\n * ```\n */\n async search(\n params: CvxSearchParams,\n options?: SearchOptions\n ): Promise<SearchResponse<CvxData>> {\n return this.http.search<SearchResponse<CvxData>>(\"/v1/cvx/search\", {\n ...params,\n ...options,\n include: options?.include?.join(\",\"),\n });\n }\n}\n","import type { HttpClient } from \"../http.js\";\nimport type {\n ApiResponse,\n BatchResponse,\n LookupOptions,\n BatchLookupOptions,\n SearchOptions,\n SearchResponse,\n} from \"../types/common.js\";\nimport type { MvxData, MvxSearchParams } from \"../types/mvx.js\";\n\n/**\n * MVX (Vaccine Manufacturer Codes) API endpoint.\n */\nexport class MvxEndpoint {\n constructor(private readonly http: HttpClient) {}\n\n /**\n * Look up a single MVX code.\n *\n * @param mvxCode - MVX manufacturer code\n * @param options - Response shape and include options\n * @returns MVX data\n *\n * @example\n * ```ts\n * const mvx = await client.mvx.lookup(\"PFR\");\n * console.log(mvx.data.manufacturer_name); // \"Pfizer, Inc\"\n * ```\n */\n async lookup(mvxCode: string, options?: LookupOptions): Promise<ApiResponse<MvxData>> {\n return this.http.get<ApiResponse<MvxData>>(`/v1/mvx/${encodeURIComponent(mvxCode)}`, options);\n }\n\n /**\n * Look up multiple MVX codes in a single request.\n *\n * @param mvxCodes - Array of MVX codes (max 500)\n * @param options - Response shape, include, and batch options\n * @returns Batch response with results for each code\n */\n async lookupMany(\n mvxCodes: string[],\n options?: BatchLookupOptions\n ): Promise<BatchResponse<MvxData>> {\n return this.http.post<BatchResponse<MvxData>>(\n \"/v1/mvx/_batch\",\n { codes: mvxCodes },\n options\n );\n }\n\n /**\n * Search for vaccine manufacturers.\n *\n * @param params - Search parameters (q, status)\n * @param options - Pagination and response shape options\n * @returns Search results with facets\n *\n * @example\n * ```ts\n * // Search by name\n * const results = await client.mvx.search({ q: \"pfizer\" });\n *\n * // List all active manufacturers\n * const results = await client.mvx.search({ status: \"active\" });\n * ```\n */\n async search(\n params: MvxSearchParams,\n options?: SearchOptions\n ): Promise<SearchResponse<MvxData>> {\n return this.http.search<SearchResponse<MvxData>>(\"/v1/mvx/search\", {\n ...params,\n ...options,\n include: options?.include?.join(\",\"),\n });\n }\n}\n","import type { HttpClient } from \"../http.js\";\nimport type {\n ApiResponse,\n BatchResponse,\n LookupOptions,\n BatchLookupOptions,\n SearchOptions,\n SearchResponse,\n} from \"../types/common.js\";\nimport type { FdaLabelData, FdaLabelSearchParams } from \"../types/fda-labels.js\";\n\n/**\n * FDA Labels API endpoint.\n */\nexport class FdaLabelsEndpoint {\n constructor(private readonly http: HttpClient) {}\n\n /**\n * Look up FDA label by identifier (Set ID, NDC, or RxCUI).\n *\n * The API auto-detects the identifier type based on format.\n *\n * @param identifier - FDA SPL Set ID, NDC code, or RxCUI\n * @param options - Response shape and include options\n * @returns FDA Label data\n *\n * @example\n * ```ts\n * // By Set ID\n * const label = await client.fdaLabels.lookup(\"abc123-def456\");\n *\n * // By NDC\n * const label = await client.fdaLabels.lookup(\"0069-0151-01\");\n *\n * // By RxCUI\n * const label = await client.fdaLabels.lookup(\"404773\");\n * ```\n */\n async lookup(identifier: string, options?: LookupOptions): Promise<ApiResponse<FdaLabelData>> {\n return this.http.get<ApiResponse<FdaLabelData>>(`/v1/fda-label/${encodeURIComponent(identifier)}`, options);\n }\n\n /**\n * Look up multiple FDA labels by identifiers in a single request.\n *\n * Identifiers can be Set IDs, NDC codes, or RxCUIs (mixed).\n *\n * @param identifiers - Array of identifiers (max 500)\n * @param options - Response shape, include, and batch options\n * @returns Batch response with results for each identifier\n */\n async lookupMany(\n identifiers: string[],\n options?: BatchLookupOptions\n ): Promise<BatchResponse<FdaLabelData>> {\n return this.http.post<BatchResponse<FdaLabelData>>(\n \"/v1/fda-label/_batch\",\n { identifiers },\n options\n );\n }\n\n /**\n * Search for FDA drug labels.\n *\n * @param params - Search parameters (q, name, brand, substance, manufacturer, etc.)\n * @param options - Pagination and response shape options\n * @returns Search results with facets\n *\n * @example\n * ```ts\n * // Search by drug name\n * const results = await client.fdaLabels.search({ q: \"advil\" });\n *\n * // Search OTC pain relievers\n * const results = await client.fdaLabels.search({\n * substance: \"acetaminophen\",\n * product_type: \"otc\"\n * });\n *\n * // Search by manufacturer\n * const results = await client.fdaLabels.search({\n * manufacturer: \"pfizer\",\n * product_type: \"rx\"\n * });\n * ```\n */\n async search(\n params: FdaLabelSearchParams,\n options?: SearchOptions\n ): Promise<SearchResponse<FdaLabelData>> {\n return this.http.search<SearchResponse<FdaLabelData>>(\"/v1/fda-label/search\", {\n ...params,\n ...options,\n include: options?.include?.join(\",\"),\n });\n }\n}\n","import type { HttpClient } from \"../http.js\";\nimport type { NpiConnectivityData } from \"../types/connectivity.js\";\n\n/**\n * Connectivity Intelligence API endpoint.\n *\n * Provides methods for looking up connectivity options (FHIR endpoints,\n * Direct addresses, etc.) for healthcare providers by NPI.\n */\nexport class ConnectivityEndpoint {\n constructor(private readonly http: HttpClient) {}\n\n /**\n * Look up connectivity options for a provider by NPI.\n *\n * Returns organizations linked to this NPI and their available endpoints\n * (FHIR servers, Direct addresses, etc.) with verification evidence and\n * availability metrics.\n *\n * @param npi - 10-digit NPI number\n * @returns Connectivity information including endpoints and verification status\n *\n * @example\n * ```ts\n * const result = await client.connectivity.lookup(\"1234567890\");\n *\n * console.log(`Provider: ${result.provider_summary.name}`);\n * console.log(`Found ${result.connectivity_targets.length} organization(s)`);\n *\n * for (const target of result.connectivity_targets) {\n * console.log(`\\n${target.name} (${target.ehr_vendor || 'Unknown EHR'})`);\n * console.log(` Link: ${target.link_type} (${target.link_confidence} confidence)`);\n *\n * for (const endpoint of target.endpoints) {\n * console.log(` - ${endpoint.type}: ${endpoint.url}`);\n * console.log(` Status: ${endpoint.status}`);\n * if (endpoint.availability) {\n * console.log(` Availability: ${endpoint.availability.percentage}%`);\n * }\n * }\n * }\n * ```\n */\n async lookup(npi: string): Promise<NpiConnectivityData> {\n return this.http.get<NpiConnectivityData>(\n `/v1/npi/${encodeURIComponent(npi)}/connectivity`\n );\n }\n}\n","import type { HttpClient } from \"../http.js\";\nimport type { ApiResponse } from \"../types/common.js\";\nimport type {\n SnomedConcept,\n SnomedReverseMappingData,\n SnomedSearchParams,\n SnomedCategoriesResponse,\n SnomedBatchResultItem,\n} from \"../types/snomed.js\";\n\n/**\n * Search result for SNOMED IPS concepts.\n */\nexport interface SnomedSearchResponse {\n count: number;\n results: SnomedConcept[];\n meta: {\n legal: {\n license: string;\n attribution_required: boolean;\n source_name: string;\n citation: string;\n };\n };\n}\n\n/**\n * Batch response for SNOMED concept lookups.\n */\nexport interface SnomedBatchResponse {\n count: number;\n results: SnomedBatchResultItem[];\n meta: {\n legal: {\n license: string;\n attribution_required: boolean;\n source_name: string;\n citation: string;\n };\n };\n}\n\n/**\n * SNOMED CT API endpoint.\n *\n * Provides access to SNOMED CT concepts from the IPS (International Patient Set)\n * free set, which contains ~12,000 curated clinical concepts licensed under CC BY 4.0.\n *\n * Unlike other endpoints, SNOMED does not use response shapes (compact/standard/full).\n */\nexport class SnomedEndpoint {\n constructor(private readonly http: HttpClient) {}\n\n /**\n * Look up a single SNOMED CT concept by concept ID.\n *\n * @param conceptId - SNOMED concept ID (numeric string, e.g., \"73211009\")\n * @returns SNOMED concept data with licensing metadata\n *\n * @example\n * ```ts\n * const result = await client.snomed.lookup(\"73211009\");\n * console.log(result.data.preferred_term); // \"Diabetes mellitus\"\n * console.log(result.data.ips_category); // \"condition\"\n * ```\n */\n async lookup(conceptId: string): Promise<ApiResponse<SnomedConcept>> {\n return this.http.get<ApiResponse<SnomedConcept>>(\n `/v1/snomed/${encodeURIComponent(conceptId)}`\n );\n }\n\n /**\n * Look up multiple SNOMED CT concepts in a single request.\n *\n * @param conceptIds - Array of SNOMED concept IDs (max 100)\n * @returns Batch response with results for each concept ID\n *\n * @example\n * ```ts\n * const result = await client.snomed.lookupMany([\"73211009\", \"84114007\"]);\n * for (const item of result.results) {\n * if (item.status === \"ok\") {\n * console.log(`${item.concept_id}: ${item.data.preferred_term}`);\n * }\n * }\n * ```\n */\n async lookupMany(conceptIds: string[]): Promise<SnomedBatchResponse> {\n return this.http.post<SnomedBatchResponse>(\n \"/v1/snomed/_batch\",\n { concept_ids: conceptIds }\n );\n }\n\n /**\n * Search SNOMED CT IPS concepts.\n *\n * @param params - Search parameters (q, ips_category, semantic_tag, active, limit, skip)\n * @returns Search results with matching concepts\n *\n * @example\n * ```ts\n * // Text search\n * const results = await client.snomed.search({ q: \"heart failure\" });\n *\n * // Filter by category\n * const conditions = await client.snomed.search({\n * ips_category: \"condition\",\n * limit: 20\n * });\n * ```\n */\n async search(params: SnomedSearchParams): Promise<SnomedSearchResponse> {\n return this.http.search<SnomedSearchResponse>(\"/v1/snomed/search\", {\n ...params,\n });\n }\n\n /**\n * List all available IPS categories.\n *\n * @returns Categories with descriptions\n *\n * @example\n * ```ts\n * const result = await client.snomed.categories();\n * console.log(result.categories); // [\"substance\", \"product\", \"condition\", ...]\n * ```\n */\n async categories(): Promise<SnomedCategoriesResponse> {\n return this.http.get<SnomedCategoriesResponse>(\"/v1/snomed/categories\");\n }\n\n /**\n * Look up reverse mappings for a SNOMED concept.\n *\n * Returns what terminology codes (ICD-10, RxNorm, NDC) map to this SNOMED concept.\n *\n * @param conceptId - SNOMED concept ID (numeric string)\n * @returns Reverse mapping data showing source codes that map to this concept\n *\n * @example\n * ```ts\n * const result = await client.snomed.mappings(\"73211009\");\n * console.log(result.data.snomed_display); // \"Diabetes mellitus\"\n * for (const mapping of result.data.mappings) {\n * console.log(`${mapping.source_system}: ${mapping.source_code}`);\n * }\n * ```\n */\n async mappings(conceptId: string): Promise<ApiResponse<SnomedReverseMappingData>> {\n return this.http.get<ApiResponse<SnomedReverseMappingData>>(\n `/v1/snomed/${encodeURIComponent(conceptId)}/mappings`\n );\n }\n}\n","import { HttpClient, TokenManager, type HttpClientConfig } from \"./http.js\";\nimport { NdcEndpoint } from \"./endpoints/ndc.js\";\nimport { NpiEndpoint } from \"./endpoints/npi.js\";\nimport { RxNormEndpoint } from \"./endpoints/rxnorm.js\";\nimport { LoincEndpoint } from \"./endpoints/loinc.js\";\nimport { Icd10Endpoint } from \"./endpoints/icd10.js\";\nimport { CvxEndpoint } from \"./endpoints/cvx.js\";\nimport { MvxEndpoint } from \"./endpoints/mvx.js\";\nimport { FdaLabelsEndpoint } from \"./endpoints/fda-labels.js\";\nimport { ConnectivityEndpoint } from \"./endpoints/connectivity.js\";\nimport { SnomedEndpoint } from \"./endpoints/snomed.js\";\n\n/**\n * Base configuration options shared by all auth modes.\n */\ninterface FhirflyBaseConfig {\n /**\n * Base URL for the API.\n * @default \"https://api.fhirfly.io\"\n */\n baseUrl?: string;\n\n /**\n * Request timeout in milliseconds.\n * @default 30000\n */\n timeout?: number;\n\n /**\n * Maximum number of retry attempts for failed requests.\n * @default 3\n */\n maxRetries?: number;\n\n /**\n * Base delay between retries in milliseconds (exponential backoff).\n * @default 1000\n */\n retryDelay?: number;\n}\n\n/**\n * Configuration using an API key (simple credentials).\n */\nexport interface FhirflyApiKeyConfig extends FhirflyBaseConfig {\n /**\n * Your FHIRfly API key.\n * Get one at https://fhirfly.io/dashboard\n */\n apiKey: string;\n clientId?: never;\n clientSecret?: never;\n tokenUrl?: never;\n scopes?: never;\n}\n\n/**\n * Configuration using OAuth2 client credentials (secure credentials).\n */\nexport interface FhirflyOAuthConfig extends FhirflyBaseConfig {\n /**\n * OAuth2 client ID from your secure credential.\n */\n clientId: string;\n\n /**\n * OAuth2 client secret from your secure credential.\n */\n clientSecret: string;\n\n /**\n * OAuth2 token endpoint URL.\n * @default \"{baseUrl}/oauth2/token\"\n */\n tokenUrl?: string;\n\n /**\n * OAuth2 scopes to request.\n */\n scopes?: string[];\n\n apiKey?: never;\n}\n\n/**\n * Configuration options for the FHIRfly client.\n * Provide either `apiKey` OR `clientId`+`clientSecret`, not both.\n */\nexport type FhirflyConfig = FhirflyApiKeyConfig | FhirflyOAuthConfig;\n\n/**\n * FHIRfly API client.\n *\n * Provides access to healthcare reference data including drug codes (NDC, RxNorm),\n * provider identifiers (NPI), lab codes (LOINC), diagnosis codes (ICD-10),\n * vaccine codes (CVX, MVX), and FDA drug labels.\n *\n * @example\n * ```ts\n * import { Fhirfly } from \"@fhirfly/sdk\";\n *\n * // Option A: API key (simple)\n * const client = new Fhirfly({ apiKey: \"ffly_sk_live_...\" });\n *\n * // Option B: Client credentials (secure)\n * const client = new Fhirfly({\n * clientId: \"ffly_client_...\",\n * clientSecret: \"ffly_secret_...\",\n * });\n *\n * // Look up a drug by NDC\n * const ndc = await client.ndc.lookup(\"0069-0151-01\");\n * console.log(ndc.data.product_name); // \"Lipitor\"\n * ```\n */\nexport class Fhirfly {\n private readonly http: HttpClient;\n\n /**\n * NDC (National Drug Code) lookups.\n */\n readonly ndc: NdcEndpoint;\n\n /**\n * NPI (National Provider Identifier) lookups.\n */\n readonly npi: NpiEndpoint;\n\n /**\n * RxNorm drug terminology lookups.\n */\n readonly rxnorm: RxNormEndpoint;\n\n /**\n * LOINC laboratory and clinical observation code lookups.\n */\n readonly loinc: LoincEndpoint;\n\n /**\n * ICD-10 diagnosis and procedure code lookups.\n */\n readonly icd10: Icd10Endpoint;\n\n /**\n * CVX vaccine code lookups.\n */\n readonly cvx: CvxEndpoint;\n\n /**\n * MVX vaccine manufacturer code lookups.\n */\n readonly mvx: MvxEndpoint;\n\n /**\n * FDA drug label lookups.\n */\n readonly fdaLabels: FdaLabelsEndpoint;\n\n /**\n * Connectivity Intelligence lookups.\n * Find FHIR endpoints, Direct addresses, and other connectivity options for providers.\n */\n readonly connectivity: ConnectivityEndpoint;\n\n /**\n * SNOMED CT IPS (International Patient Set) lookups.\n * Look up clinical concepts from the SNOMED CT IPS free set (~12K concepts, CC BY 4.0).\n */\n readonly snomed: SnomedEndpoint;\n\n /**\n * Create a new FHIRfly client.\n *\n * @param config - Client configuration (API key or OAuth2 client credentials)\n * @throws {Error} If neither apiKey nor clientId+clientSecret is provided\n */\n constructor(config: FhirflyConfig) {\n const baseUrl = config.baseUrl ?? \"https://api.fhirfly.io\";\n\n let httpConfig: HttpClientConfig;\n\n if (\"apiKey\" in config && config.apiKey) {\n httpConfig = {\n baseUrl,\n auth: { type: \"api-key\", apiKey: config.apiKey },\n timeout: config.timeout,\n maxRetries: config.maxRetries,\n retryDelay: config.retryDelay,\n };\n } else if (\"clientId\" in config && config.clientId && config.clientSecret) {\n const tokenManager = new TokenManager({\n clientId: config.clientId,\n clientSecret: config.clientSecret,\n tokenUrl: config.tokenUrl ?? `${baseUrl}/oauth2/token`,\n scopes: config.scopes,\n });\n httpConfig = {\n baseUrl,\n auth: { type: \"oauth\", tokenManager },\n timeout: config.timeout,\n maxRetries: config.maxRetries,\n retryDelay: config.retryDelay,\n };\n } else {\n throw new Error(\n \"FHIRfly requires either an apiKey or clientId+clientSecret. Get credentials at https://fhirfly.io/dashboard\"\n );\n }\n\n this.http = new HttpClient(httpConfig);\n\n // Initialize endpoints\n this.ndc = new NdcEndpoint(this.http);\n this.npi = new NpiEndpoint(this.http);\n this.rxnorm = new RxNormEndpoint(this.http);\n this.loinc = new LoincEndpoint(this.http);\n this.icd10 = new Icd10Endpoint(this.http);\n this.cvx = new CvxEndpoint(this.http);\n this.mvx = new MvxEndpoint(this.http);\n this.fdaLabels = new FdaLabelsEndpoint(this.http);\n this.connectivity = new ConnectivityEndpoint(this.http);\n this.snomed = new SnomedEndpoint(this.http);\n }\n}\n"]}