@fhirfly-io/terminology 0.3.2 → 0.3.3

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,49 @@ 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
+
941
984
  // src/client.ts
942
985
  var Fhirfly = class {
943
986
  http;
@@ -973,6 +1016,11 @@ var Fhirfly = class {
973
1016
  * FDA drug label lookups.
974
1017
  */
975
1018
  fdaLabels;
1019
+ /**
1020
+ * Connectivity Intelligence lookups.
1021
+ * Find FHIR endpoints, Direct addresses, and other connectivity options for providers.
1022
+ */
1023
+ connectivity;
976
1024
  /**
977
1025
  * Create a new FHIRfly client.
978
1026
  *
@@ -1018,6 +1066,7 @@ var Fhirfly = class {
1018
1066
  this.cvx = new CvxEndpoint(this.http);
1019
1067
  this.mvx = new MvxEndpoint(this.http);
1020
1068
  this.fdaLabels = new FdaLabelsEndpoint(this.http);
1069
+ this.connectivity = new ConnectivityEndpoint(this.http);
1021
1070
  }
1022
1071
  };
1023
1072
 
@@ -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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,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,MAAA,GAAS,IAAI,cAAA,CAAe,IAAA,CAAK,IAAI,CAAA;AAC1C,IAAA,IAAA,CAAK,KAAA,GAAQ,IAAI,aAAA,CAAc,IAAA,CAAK,IAAI,CAAA;AACxC,IAAA,IAAA,CAAK,KAAA,GAAQ,IAAI,aAAA,CAAc,IAAA,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/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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,IAAI,CAAA;AAC1C,IAAA,IAAA,CAAK,KAAA,GAAQ,IAAI,aAAA,CAAc,IAAA,CAAK,IAAI,CAAA;AACxC,IAAA,IAAA,CAAK,KAAA,GAAQ,IAAI,aAAA,CAAc,IAAA,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;AAChD,IAAA,IAAA,CAAK,YAAA,GAAe,IAAI,oBAAA,CAAqB,IAAA,CAAK,IAAI,CAAA;AAAA,EACxD;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 { 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\";\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 * 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 }\n}\n"]}
package/dist/index.d.cts CHANGED
@@ -1290,6 +1290,198 @@ declare class FdaLabelsEndpoint {
1290
1290
  search(params: FdaLabelSearchParams, options?: SearchOptions): Promise<SearchResponse<FdaLabelData>>;
1291
1291
  }
1292
1292
 
1293
+ /**
1294
+ * Connectivity Intelligence API types.
1295
+ *
1296
+ * Types for looking up FHIR endpoints, Direct addresses, and other
1297
+ * connectivity options for healthcare providers by NPI.
1298
+ */
1299
+ /**
1300
+ * Provider summary from NPI registry.
1301
+ */
1302
+ interface ProviderSummary {
1303
+ /** Provider name (individual or organization) */
1304
+ name: string;
1305
+ /** Entity type */
1306
+ entity_type: "individual" | "organization" | "unknown";
1307
+ /** Primary taxonomy code */
1308
+ primary_taxonomy?: string;
1309
+ /** Primary taxonomy description */
1310
+ primary_taxonomy_desc?: string;
1311
+ }
1312
+ /**
1313
+ * FHIR-specific metadata for an endpoint.
1314
+ */
1315
+ interface FhirMetadata {
1316
+ /** URL to SMART configuration */
1317
+ smart_config_url?: string;
1318
+ /** SMART launch capabilities */
1319
+ capabilities?: string[];
1320
+ /** Supported FHIR resource types */
1321
+ supported_resources?: string[];
1322
+ /** Security/OAuth configuration */
1323
+ security?: {
1324
+ oauth_authorize_url?: string;
1325
+ oauth_token_url?: string;
1326
+ requires_udap?: boolean;
1327
+ };
1328
+ }
1329
+ /**
1330
+ * Auth requirements for connecting to an endpoint.
1331
+ */
1332
+ interface EndpointAuthRequirements {
1333
+ /** Whether registration is required before connecting */
1334
+ registration_required?: boolean;
1335
+ /** URL for registration (if required) */
1336
+ registration_url?: string;
1337
+ /** Whether allowlist approval is required */
1338
+ allowlist_required?: boolean;
1339
+ /** Additional notes about auth requirements */
1340
+ notes?: string;
1341
+ }
1342
+ /**
1343
+ * Availability statistics for an endpoint.
1344
+ */
1345
+ interface EndpointAvailability {
1346
+ /** Uptime percentage (e.g., 99.2) */
1347
+ percentage: number;
1348
+ /** Total number of probes recorded */
1349
+ probe_count: number;
1350
+ /** When the endpoint was last checked (ISO date) */
1351
+ last_checked: string;
1352
+ /** When the endpoint was last successfully reached (ISO date or null) */
1353
+ last_successful: string | null;
1354
+ /** Current streak of consecutive failures */
1355
+ consecutive_failures: number;
1356
+ }
1357
+ /**
1358
+ * Evidence summary for an endpoint.
1359
+ */
1360
+ interface EvidenceSummary {
1361
+ /** Type of most recent verification */
1362
+ latest_verification: string;
1363
+ /** Total number of verifications recorded */
1364
+ verification_count: number;
1365
+ /** When the endpoint was first discovered (ISO date) */
1366
+ first_seen: string;
1367
+ /** Types of evidence sources */
1368
+ sources: string[];
1369
+ }
1370
+ /**
1371
+ * Endpoint connectivity information.
1372
+ */
1373
+ interface ConnectivityEndpointData {
1374
+ /** Unique endpoint identifier */
1375
+ endpoint_id: string;
1376
+ /** Endpoint type */
1377
+ type: "fhir_r4" | "fhir_stu3" | "fhir_dstu2" | "direct" | "hl7v2_adt" | "x12" | "other";
1378
+ /** Base URL or address */
1379
+ url: string;
1380
+ /** Scope (production vs sandbox) */
1381
+ scope: "production" | "sandbox" | "unknown";
1382
+ /** Current verification status */
1383
+ status: "active" | "inactive" | "unverified" | "unreachable";
1384
+ /** When the endpoint was last verified (ISO date) */
1385
+ last_verified_at?: string;
1386
+ /** FHIR-specific metadata (if applicable) */
1387
+ fhir_metadata?: FhirMetadata;
1388
+ /** Authentication requirements */
1389
+ auth_requirements?: EndpointAuthRequirements;
1390
+ /** Availability statistics */
1391
+ availability?: EndpointAvailability;
1392
+ /** Summary of verification evidence */
1393
+ evidence_summary: EvidenceSummary;
1394
+ }
1395
+ /**
1396
+ * Connectivity target (organization/health system).
1397
+ */
1398
+ interface ConnectivityTargetData {
1399
+ /** Unique target identifier */
1400
+ target_id: string;
1401
+ /** Organization name */
1402
+ name: string;
1403
+ /** Organization type */
1404
+ type: "health_system" | "facility" | "practice" | "hie" | "qhin" | "payer";
1405
+ /** How this NPI is linked to the target */
1406
+ link_type: "organization_npi" | "employed_by" | "affiliated" | "practice_location";
1407
+ /** Confidence level of the link */
1408
+ link_confidence: "high" | "medium" | "low" | "inferred";
1409
+ /** EHR vendor (if known) */
1410
+ ehr_vendor?: string;
1411
+ /** Network participation (e.g., CommonWell, Carequality) */
1412
+ network_participation?: string[];
1413
+ /** Available endpoints for this target */
1414
+ endpoints: ConnectivityEndpointData[];
1415
+ }
1416
+ /**
1417
+ * Response metadata for connectivity lookups.
1418
+ */
1419
+ interface ConnectivityMeta {
1420
+ /** Timestamp of when this data was retrieved (ISO date) */
1421
+ data_as_of: string;
1422
+ /** Disclaimer about the data */
1423
+ disclaimer: string;
1424
+ }
1425
+ /**
1426
+ * NPI connectivity response.
1427
+ *
1428
+ * Contains all connectivity options for reaching a provider's organization,
1429
+ * including FHIR endpoints, Direct addresses, and verification evidence.
1430
+ */
1431
+ interface NpiConnectivityData {
1432
+ /** The NPI that was looked up */
1433
+ npi: string;
1434
+ /** Summary of the provider from NPPES */
1435
+ provider_summary: ProviderSummary;
1436
+ /** Organizations linked to this NPI with their endpoints */
1437
+ connectivity_targets: ConnectivityTargetData[];
1438
+ /** Response metadata */
1439
+ meta: ConnectivityMeta;
1440
+ }
1441
+
1442
+ /**
1443
+ * Connectivity Intelligence API endpoint.
1444
+ *
1445
+ * Provides methods for looking up connectivity options (FHIR endpoints,
1446
+ * Direct addresses, etc.) for healthcare providers by NPI.
1447
+ */
1448
+ declare class ConnectivityEndpoint {
1449
+ private readonly http;
1450
+ constructor(http: HttpClient);
1451
+ /**
1452
+ * Look up connectivity options for a provider by NPI.
1453
+ *
1454
+ * Returns organizations linked to this NPI and their available endpoints
1455
+ * (FHIR servers, Direct addresses, etc.) with verification evidence and
1456
+ * availability metrics.
1457
+ *
1458
+ * @param npi - 10-digit NPI number
1459
+ * @returns Connectivity information including endpoints and verification status
1460
+ *
1461
+ * @example
1462
+ * ```ts
1463
+ * const result = await client.connectivity.lookup("1234567890");
1464
+ *
1465
+ * console.log(`Provider: ${result.provider_summary.name}`);
1466
+ * console.log(`Found ${result.connectivity_targets.length} organization(s)`);
1467
+ *
1468
+ * for (const target of result.connectivity_targets) {
1469
+ * console.log(`\n${target.name} (${target.ehr_vendor || 'Unknown EHR'})`);
1470
+ * console.log(` Link: ${target.link_type} (${target.link_confidence} confidence)`);
1471
+ *
1472
+ * for (const endpoint of target.endpoints) {
1473
+ * console.log(` - ${endpoint.type}: ${endpoint.url}`);
1474
+ * console.log(` Status: ${endpoint.status}`);
1475
+ * if (endpoint.availability) {
1476
+ * console.log(` Availability: ${endpoint.availability.percentage}%`);
1477
+ * }
1478
+ * }
1479
+ * }
1480
+ * ```
1481
+ */
1482
+ lookup(npi: string): Promise<NpiConnectivityData>;
1483
+ }
1484
+
1293
1485
  /**
1294
1486
  * Base configuration options shared by all auth modes.
1295
1487
  */
@@ -1416,6 +1608,11 @@ declare class Fhirfly {
1416
1608
  * FDA drug label lookups.
1417
1609
  */
1418
1610
  readonly fdaLabels: FdaLabelsEndpoint;
1611
+ /**
1612
+ * Connectivity Intelligence lookups.
1613
+ * Find FHIR endpoints, Direct addresses, and other connectivity options for providers.
1614
+ */
1615
+ readonly connectivity: ConnectivityEndpoint;
1419
1616
  /**
1420
1617
  * Create a new FHIRfly client.
1421
1618
  *
@@ -1501,4 +1698,4 @@ declare class TimeoutError extends FhirflyError {
1501
1698
  constructor(timeoutMs: number);
1502
1699
  }
1503
1700
 
1504
- export { type ActiveIngredient, ApiError, type ApiResponse, AuthenticationError, type BatchLookupOptions, type BatchResponse, type BatchResultItem, type CvxCompact, type CvxData, type CvxFull, type CvxSearchParams, type CvxStandard, type DisplayField, type FdaLabelCompact, type FdaLabelData, type FdaLabelFull, type FdaLabelSearchParams, type FdaLabelStandard, Fhirfly, type FhirflyApiKeyConfig, type FhirflyConfig, FhirflyError, type FhirflyOAuthConfig, type Icd10Compact, type Icd10Data, type Icd10Full, type Icd10SearchParams, type Icd10Standard, type Icd10Type, type IncludeOption, type LegalInfo, type LoincCompact, type LoincData, type LoincFull, type LoincSearchParams, type LoincStandard, type LookupOptions, type MvxCompact, type MvxData, type MvxFull, type MvxSearchParams, type MvxStandard, type NdcCompact, type NdcData, type NdcFull, type NdcPackaging, type NdcSearchParams, type NdcStandard, NetworkError, NotFoundError, type NpiAddress, type NpiCompact, type NpiData, type NpiFull, type NpiIdentifier, type NpiSearchParams, type NpiStandard, type NpiTaxonomy, QuotaExceededError, RateLimitError, type ResponseMeta, type ResponseShape, type RxNormCompact, type RxNormData, type RxNormFull, type RxNormSearchParams, type RxNormStandard, type RxTermType, type SearchFacets, type SearchLegalInfo, type SearchOptions, type SearchResponse, ServerError, TimeoutError, TokenManager, ValidationError };
1701
+ export { type ActiveIngredient, ApiError, type ApiResponse, AuthenticationError, type BatchLookupOptions, type BatchResponse, type BatchResultItem, type ConnectivityEndpointData, type ConnectivityMeta, type ConnectivityTargetData, type CvxCompact, type CvxData, type CvxFull, type CvxSearchParams, type CvxStandard, type DisplayField, type EndpointAuthRequirements, type EndpointAvailability, type EvidenceSummary, type FdaLabelCompact, type FdaLabelData, type FdaLabelFull, type FdaLabelSearchParams, type FdaLabelStandard, type FhirMetadata, Fhirfly, type FhirflyApiKeyConfig, type FhirflyConfig, FhirflyError, type FhirflyOAuthConfig, type Icd10Compact, type Icd10Data, type Icd10Full, type Icd10SearchParams, type Icd10Standard, type Icd10Type, type IncludeOption, type LegalInfo, type LoincCompact, type LoincData, type LoincFull, type LoincSearchParams, type LoincStandard, type LookupOptions, type MvxCompact, type MvxData, type MvxFull, type MvxSearchParams, type MvxStandard, type NdcCompact, type NdcData, type NdcFull, type NdcPackaging, type NdcSearchParams, type NdcStandard, NetworkError, NotFoundError, type NpiAddress, type NpiCompact, type NpiConnectivityData, type NpiData, type NpiFull, type NpiIdentifier, type NpiSearchParams, type NpiStandard, type NpiTaxonomy, type ProviderSummary, QuotaExceededError, RateLimitError, type ResponseMeta, type ResponseShape, type RxNormCompact, type RxNormData, type RxNormFull, type RxNormSearchParams, type RxNormStandard, type RxTermType, type SearchFacets, type SearchLegalInfo, type SearchOptions, type SearchResponse, ServerError, TimeoutError, TokenManager, ValidationError };
package/dist/index.d.ts CHANGED
@@ -1290,6 +1290,198 @@ declare class FdaLabelsEndpoint {
1290
1290
  search(params: FdaLabelSearchParams, options?: SearchOptions): Promise<SearchResponse<FdaLabelData>>;
1291
1291
  }
1292
1292
 
1293
+ /**
1294
+ * Connectivity Intelligence API types.
1295
+ *
1296
+ * Types for looking up FHIR endpoints, Direct addresses, and other
1297
+ * connectivity options for healthcare providers by NPI.
1298
+ */
1299
+ /**
1300
+ * Provider summary from NPI registry.
1301
+ */
1302
+ interface ProviderSummary {
1303
+ /** Provider name (individual or organization) */
1304
+ name: string;
1305
+ /** Entity type */
1306
+ entity_type: "individual" | "organization" | "unknown";
1307
+ /** Primary taxonomy code */
1308
+ primary_taxonomy?: string;
1309
+ /** Primary taxonomy description */
1310
+ primary_taxonomy_desc?: string;
1311
+ }
1312
+ /**
1313
+ * FHIR-specific metadata for an endpoint.
1314
+ */
1315
+ interface FhirMetadata {
1316
+ /** URL to SMART configuration */
1317
+ smart_config_url?: string;
1318
+ /** SMART launch capabilities */
1319
+ capabilities?: string[];
1320
+ /** Supported FHIR resource types */
1321
+ supported_resources?: string[];
1322
+ /** Security/OAuth configuration */
1323
+ security?: {
1324
+ oauth_authorize_url?: string;
1325
+ oauth_token_url?: string;
1326
+ requires_udap?: boolean;
1327
+ };
1328
+ }
1329
+ /**
1330
+ * Auth requirements for connecting to an endpoint.
1331
+ */
1332
+ interface EndpointAuthRequirements {
1333
+ /** Whether registration is required before connecting */
1334
+ registration_required?: boolean;
1335
+ /** URL for registration (if required) */
1336
+ registration_url?: string;
1337
+ /** Whether allowlist approval is required */
1338
+ allowlist_required?: boolean;
1339
+ /** Additional notes about auth requirements */
1340
+ notes?: string;
1341
+ }
1342
+ /**
1343
+ * Availability statistics for an endpoint.
1344
+ */
1345
+ interface EndpointAvailability {
1346
+ /** Uptime percentage (e.g., 99.2) */
1347
+ percentage: number;
1348
+ /** Total number of probes recorded */
1349
+ probe_count: number;
1350
+ /** When the endpoint was last checked (ISO date) */
1351
+ last_checked: string;
1352
+ /** When the endpoint was last successfully reached (ISO date or null) */
1353
+ last_successful: string | null;
1354
+ /** Current streak of consecutive failures */
1355
+ consecutive_failures: number;
1356
+ }
1357
+ /**
1358
+ * Evidence summary for an endpoint.
1359
+ */
1360
+ interface EvidenceSummary {
1361
+ /** Type of most recent verification */
1362
+ latest_verification: string;
1363
+ /** Total number of verifications recorded */
1364
+ verification_count: number;
1365
+ /** When the endpoint was first discovered (ISO date) */
1366
+ first_seen: string;
1367
+ /** Types of evidence sources */
1368
+ sources: string[];
1369
+ }
1370
+ /**
1371
+ * Endpoint connectivity information.
1372
+ */
1373
+ interface ConnectivityEndpointData {
1374
+ /** Unique endpoint identifier */
1375
+ endpoint_id: string;
1376
+ /** Endpoint type */
1377
+ type: "fhir_r4" | "fhir_stu3" | "fhir_dstu2" | "direct" | "hl7v2_adt" | "x12" | "other";
1378
+ /** Base URL or address */
1379
+ url: string;
1380
+ /** Scope (production vs sandbox) */
1381
+ scope: "production" | "sandbox" | "unknown";
1382
+ /** Current verification status */
1383
+ status: "active" | "inactive" | "unverified" | "unreachable";
1384
+ /** When the endpoint was last verified (ISO date) */
1385
+ last_verified_at?: string;
1386
+ /** FHIR-specific metadata (if applicable) */
1387
+ fhir_metadata?: FhirMetadata;
1388
+ /** Authentication requirements */
1389
+ auth_requirements?: EndpointAuthRequirements;
1390
+ /** Availability statistics */
1391
+ availability?: EndpointAvailability;
1392
+ /** Summary of verification evidence */
1393
+ evidence_summary: EvidenceSummary;
1394
+ }
1395
+ /**
1396
+ * Connectivity target (organization/health system).
1397
+ */
1398
+ interface ConnectivityTargetData {
1399
+ /** Unique target identifier */
1400
+ target_id: string;
1401
+ /** Organization name */
1402
+ name: string;
1403
+ /** Organization type */
1404
+ type: "health_system" | "facility" | "practice" | "hie" | "qhin" | "payer";
1405
+ /** How this NPI is linked to the target */
1406
+ link_type: "organization_npi" | "employed_by" | "affiliated" | "practice_location";
1407
+ /** Confidence level of the link */
1408
+ link_confidence: "high" | "medium" | "low" | "inferred";
1409
+ /** EHR vendor (if known) */
1410
+ ehr_vendor?: string;
1411
+ /** Network participation (e.g., CommonWell, Carequality) */
1412
+ network_participation?: string[];
1413
+ /** Available endpoints for this target */
1414
+ endpoints: ConnectivityEndpointData[];
1415
+ }
1416
+ /**
1417
+ * Response metadata for connectivity lookups.
1418
+ */
1419
+ interface ConnectivityMeta {
1420
+ /** Timestamp of when this data was retrieved (ISO date) */
1421
+ data_as_of: string;
1422
+ /** Disclaimer about the data */
1423
+ disclaimer: string;
1424
+ }
1425
+ /**
1426
+ * NPI connectivity response.
1427
+ *
1428
+ * Contains all connectivity options for reaching a provider's organization,
1429
+ * including FHIR endpoints, Direct addresses, and verification evidence.
1430
+ */
1431
+ interface NpiConnectivityData {
1432
+ /** The NPI that was looked up */
1433
+ npi: string;
1434
+ /** Summary of the provider from NPPES */
1435
+ provider_summary: ProviderSummary;
1436
+ /** Organizations linked to this NPI with their endpoints */
1437
+ connectivity_targets: ConnectivityTargetData[];
1438
+ /** Response metadata */
1439
+ meta: ConnectivityMeta;
1440
+ }
1441
+
1442
+ /**
1443
+ * Connectivity Intelligence API endpoint.
1444
+ *
1445
+ * Provides methods for looking up connectivity options (FHIR endpoints,
1446
+ * Direct addresses, etc.) for healthcare providers by NPI.
1447
+ */
1448
+ declare class ConnectivityEndpoint {
1449
+ private readonly http;
1450
+ constructor(http: HttpClient);
1451
+ /**
1452
+ * Look up connectivity options for a provider by NPI.
1453
+ *
1454
+ * Returns organizations linked to this NPI and their available endpoints
1455
+ * (FHIR servers, Direct addresses, etc.) with verification evidence and
1456
+ * availability metrics.
1457
+ *
1458
+ * @param npi - 10-digit NPI number
1459
+ * @returns Connectivity information including endpoints and verification status
1460
+ *
1461
+ * @example
1462
+ * ```ts
1463
+ * const result = await client.connectivity.lookup("1234567890");
1464
+ *
1465
+ * console.log(`Provider: ${result.provider_summary.name}`);
1466
+ * console.log(`Found ${result.connectivity_targets.length} organization(s)`);
1467
+ *
1468
+ * for (const target of result.connectivity_targets) {
1469
+ * console.log(`\n${target.name} (${target.ehr_vendor || 'Unknown EHR'})`);
1470
+ * console.log(` Link: ${target.link_type} (${target.link_confidence} confidence)`);
1471
+ *
1472
+ * for (const endpoint of target.endpoints) {
1473
+ * console.log(` - ${endpoint.type}: ${endpoint.url}`);
1474
+ * console.log(` Status: ${endpoint.status}`);
1475
+ * if (endpoint.availability) {
1476
+ * console.log(` Availability: ${endpoint.availability.percentage}%`);
1477
+ * }
1478
+ * }
1479
+ * }
1480
+ * ```
1481
+ */
1482
+ lookup(npi: string): Promise<NpiConnectivityData>;
1483
+ }
1484
+
1293
1485
  /**
1294
1486
  * Base configuration options shared by all auth modes.
1295
1487
  */
@@ -1416,6 +1608,11 @@ declare class Fhirfly {
1416
1608
  * FDA drug label lookups.
1417
1609
  */
1418
1610
  readonly fdaLabels: FdaLabelsEndpoint;
1611
+ /**
1612
+ * Connectivity Intelligence lookups.
1613
+ * Find FHIR endpoints, Direct addresses, and other connectivity options for providers.
1614
+ */
1615
+ readonly connectivity: ConnectivityEndpoint;
1419
1616
  /**
1420
1617
  * Create a new FHIRfly client.
1421
1618
  *
@@ -1501,4 +1698,4 @@ declare class TimeoutError extends FhirflyError {
1501
1698
  constructor(timeoutMs: number);
1502
1699
  }
1503
1700
 
1504
- export { type ActiveIngredient, ApiError, type ApiResponse, AuthenticationError, type BatchLookupOptions, type BatchResponse, type BatchResultItem, type CvxCompact, type CvxData, type CvxFull, type CvxSearchParams, type CvxStandard, type DisplayField, type FdaLabelCompact, type FdaLabelData, type FdaLabelFull, type FdaLabelSearchParams, type FdaLabelStandard, Fhirfly, type FhirflyApiKeyConfig, type FhirflyConfig, FhirflyError, type FhirflyOAuthConfig, type Icd10Compact, type Icd10Data, type Icd10Full, type Icd10SearchParams, type Icd10Standard, type Icd10Type, type IncludeOption, type LegalInfo, type LoincCompact, type LoincData, type LoincFull, type LoincSearchParams, type LoincStandard, type LookupOptions, type MvxCompact, type MvxData, type MvxFull, type MvxSearchParams, type MvxStandard, type NdcCompact, type NdcData, type NdcFull, type NdcPackaging, type NdcSearchParams, type NdcStandard, NetworkError, NotFoundError, type NpiAddress, type NpiCompact, type NpiData, type NpiFull, type NpiIdentifier, type NpiSearchParams, type NpiStandard, type NpiTaxonomy, QuotaExceededError, RateLimitError, type ResponseMeta, type ResponseShape, type RxNormCompact, type RxNormData, type RxNormFull, type RxNormSearchParams, type RxNormStandard, type RxTermType, type SearchFacets, type SearchLegalInfo, type SearchOptions, type SearchResponse, ServerError, TimeoutError, TokenManager, ValidationError };
1701
+ export { type ActiveIngredient, ApiError, type ApiResponse, AuthenticationError, type BatchLookupOptions, type BatchResponse, type BatchResultItem, type ConnectivityEndpointData, type ConnectivityMeta, type ConnectivityTargetData, type CvxCompact, type CvxData, type CvxFull, type CvxSearchParams, type CvxStandard, type DisplayField, type EndpointAuthRequirements, type EndpointAvailability, type EvidenceSummary, type FdaLabelCompact, type FdaLabelData, type FdaLabelFull, type FdaLabelSearchParams, type FdaLabelStandard, type FhirMetadata, Fhirfly, type FhirflyApiKeyConfig, type FhirflyConfig, FhirflyError, type FhirflyOAuthConfig, type Icd10Compact, type Icd10Data, type Icd10Full, type Icd10SearchParams, type Icd10Standard, type Icd10Type, type IncludeOption, type LegalInfo, type LoincCompact, type LoincData, type LoincFull, type LoincSearchParams, type LoincStandard, type LookupOptions, type MvxCompact, type MvxData, type MvxFull, type MvxSearchParams, type MvxStandard, type NdcCompact, type NdcData, type NdcFull, type NdcPackaging, type NdcSearchParams, type NdcStandard, NetworkError, NotFoundError, type NpiAddress, type NpiCompact, type NpiConnectivityData, type NpiData, type NpiFull, type NpiIdentifier, type NpiSearchParams, type NpiStandard, type NpiTaxonomy, type ProviderSummary, QuotaExceededError, RateLimitError, type ResponseMeta, type ResponseShape, type RxNormCompact, type RxNormData, type RxNormFull, type RxNormSearchParams, type RxNormStandard, type RxTermType, type SearchFacets, type SearchLegalInfo, type SearchOptions, type SearchResponse, ServerError, TimeoutError, TokenManager, ValidationError };
package/dist/index.js CHANGED
@@ -936,6 +936,49 @@ var FdaLabelsEndpoint = class {
936
936
  }
937
937
  };
938
938
 
939
+ // src/endpoints/connectivity.ts
940
+ var ConnectivityEndpoint = class {
941
+ constructor(http) {
942
+ this.http = http;
943
+ }
944
+ /**
945
+ * Look up connectivity options for a provider by NPI.
946
+ *
947
+ * Returns organizations linked to this NPI and their available endpoints
948
+ * (FHIR servers, Direct addresses, etc.) with verification evidence and
949
+ * availability metrics.
950
+ *
951
+ * @param npi - 10-digit NPI number
952
+ * @returns Connectivity information including endpoints and verification status
953
+ *
954
+ * @example
955
+ * ```ts
956
+ * const result = await client.connectivity.lookup("1234567890");
957
+ *
958
+ * console.log(`Provider: ${result.provider_summary.name}`);
959
+ * console.log(`Found ${result.connectivity_targets.length} organization(s)`);
960
+ *
961
+ * for (const target of result.connectivity_targets) {
962
+ * console.log(`\n${target.name} (${target.ehr_vendor || 'Unknown EHR'})`);
963
+ * console.log(` Link: ${target.link_type} (${target.link_confidence} confidence)`);
964
+ *
965
+ * for (const endpoint of target.endpoints) {
966
+ * console.log(` - ${endpoint.type}: ${endpoint.url}`);
967
+ * console.log(` Status: ${endpoint.status}`);
968
+ * if (endpoint.availability) {
969
+ * console.log(` Availability: ${endpoint.availability.percentage}%`);
970
+ * }
971
+ * }
972
+ * }
973
+ * ```
974
+ */
975
+ async lookup(npi) {
976
+ return this.http.get(
977
+ `/v1/npi/${encodeURIComponent(npi)}/connectivity`
978
+ );
979
+ }
980
+ };
981
+
939
982
  // src/client.ts
940
983
  var Fhirfly = class {
941
984
  http;
@@ -971,6 +1014,11 @@ var Fhirfly = class {
971
1014
  * FDA drug label lookups.
972
1015
  */
973
1016
  fdaLabels;
1017
+ /**
1018
+ * Connectivity Intelligence lookups.
1019
+ * Find FHIR endpoints, Direct addresses, and other connectivity options for providers.
1020
+ */
1021
+ connectivity;
974
1022
  /**
975
1023
  * Create a new FHIRfly client.
976
1024
  *
@@ -1016,6 +1064,7 @@ var Fhirfly = class {
1016
1064
  this.cvx = new CvxEndpoint(this.http);
1017
1065
  this.mvx = new MvxEndpoint(this.http);
1018
1066
  this.fdaLabels = new FdaLabelsEndpoint(this.http);
1067
+ this.connectivity = new ConnectivityEndpoint(this.http);
1019
1068
  }
1020
1069
  };
1021
1070
 
package/dist/index.js.map CHANGED
@@ -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,C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AAAA,OAChB,CAAA;AACD,MAAA,UAAA,GAAa;AAAA,QACX,OAAA;AAAA,QACA,IAAA,EAAM,EAAE,IAAA,EAAM,OAAA,EAAS,YAAA,EAAa;AAAA,QACpC,SAAS,MAAA,CAAO,OAAA;AAAA,QAChB,YAAY,MAAA,CAAO,UAAA;AAAA,QACnB,YAAY,MAAA,CAAO;AAAA,OACrB;AAAA,IACF,CAAA,MAAO;AACL,MAAA,MAAM,IAAI,KAAA;AAAA,QACR;AAAA,OACF;AAAA,IACF;AAEA,IAAA,IAAA,CAAK,IAAA,GAAO,IAAI,UAAA,CAAW,UAAU,CAAA;AAGrC,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,MAAA,GAAS,IAAI,cAAA,CAAe,IAAA,CAAK,IAAI,CAAA;AAC1C,IAAA,IAAA,CAAK,KAAA,GAAQ,IAAI,aAAA,CAAc,IAAA,CAAK,IAAI,CAAA;AACxC,IAAA,IAAA,CAAK,KAAA,GAAQ,IAAI,aAAA,CAAc,IAAA,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.js","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/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,c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AY,MAAA,CAAO;AAAA,OACrB;AAAA,IACF,CAAA,MAAO;AACL,MAAA,MAAM,IAAI,KAAA;AAAA,QACR;AAAA,OACF;AAAA,IACF;AAEA,IAAA,IAAA,CAAK,IAAA,GAAO,IAAI,UAAA,CAAW,UAAU,CAAA;AAGrC,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,MAAA,GAAS,IAAI,cAAA,CAAe,IAAA,CAAK,IAAI,CAAA;AAC1C,IAAA,IAAA,CAAK,KAAA,GAAQ,IAAI,aAAA,CAAc,IAAA,CAAK,IAAI,CAAA;AACxC,IAAA,IAAA,CAAK,KAAA,GAAQ,IAAI,aAAA,CAAc,IAAA,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;AAChD,IAAA,IAAA,CAAK,YAAA,GAAe,IAAI,oBAAA,CAAqB,IAAA,CAAK,IAAI,CAAA;AAAA,EACxD;AACF","file":"index.js","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 { 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\";\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 * 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 }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fhirfly-io/terminology",
3
- "version": "0.3.2",
3
+ "version": "0.3.3",
4
4
  "description": "Official FHIRfly SDK for Node.js - Healthcare reference data APIs",
5
5
  "author": "FHIRfly.io LLC <admin@fhirfly.io>",
6
6
  "license": "MIT",