### Install Project Dependencies Source: https://github.com/candidhealth/candid-node/blob/master/CONTRIBUTING.md Run this command to install all necessary project dependencies. ```bash yarn install ``` -------------------------------- ### Install Candid Health SDK Source: https://github.com/candidhealth/candid-node/blob/master/_autodocs/README.md Install the Candid Health Node.js SDK using npm. ```sh npm install candidhealth ``` -------------------------------- ### Complete CandidApiClient Configuration Example Source: https://github.com/candidhealth/candid-node/blob/master/_autodocs/configuration.md A comprehensive example demonstrating various configuration options for the CandidApiClient, including authentication, environment, timeouts, retries, custom headers, and logging. ```typescript import { CandidApiClient, CandidApiEnvironment, logging } from "candidhealth"; const client = new CandidApiClient({ // Authentication (choose one) clientId: process.env.CANDID_CLIENT_ID || "", clientSecret: process.env.CANDID_CLIENT_SECRET || "", // OR: token: process.env.CANDID_TOKEN || "", // Environment environment: process.env.NODE_ENV === "production" ? CandidApiEnvironment.Production : CandidApiEnvironment.Staging, // Timeouts and Retries timeoutInSeconds: 120, maxRetries: 3, // Headers headers: { "X-Application": "my-healthcare-app", "X-Version": "1.0.0", "X-Request-Source": async () => { const requestId = await generateRequestId(); return `app-${requestId}`; } }, // Logging logging: { level: process.env.LOG_LEVEL as logging.LogLevel || logging.LogLevel.Info, logger: new logging.ConsoleLogger(), silent: process.env.LOG_SILENT === "true" }, // Custom fetch (optional) fetch: undefined // Use default fetch or provide custom }); // Use the client await client.encounters.v4.getAll({ limit: 100 }); ``` -------------------------------- ### Install Candid TypeScript Library Source: https://github.com/candidhealth/candid-node/blob/master/README.md Install the Candid TypeScript library using npm. ```sh npm i -s candidhealth ``` -------------------------------- ### Integrate Pino Logger Source: https://github.com/candidhealth/candid-node/blob/master/_autodocs/api-reference/05-logging.md Integrate Pino for high-performance JSON logging. This setup uses 'pino-pretty' for human-readable output during development. Ensure Pino and the 'pino-pretty' transport are installed. ```typescript import { CandidApiClient, logging } from "candidhealth"; import pino from "pino"; const pinoLogger = pino({ level: "debug", transport: { target: "pino-pretty" } }); const customLogger: logging.ILogger = { debug: (msg, ...args) => pinoLogger.debug(args, msg), info: (msg, ...args) => pinoLogger.info(args, msg), warn: (msg, ...args) => pinoLogger.warn(args, msg), error: (msg, ...args) => pinoLogger.error(args, msg) }; const client = new CandidApiClient({ clientId: "...", clientSecret: "...", logging: { level: logging.LogLevel.Debug, logger: customLogger, silent: false } }); ``` -------------------------------- ### Complex Request Example Source: https://github.com/candidhealth/candid-node/blob/master/_autodocs/api-reference/04-request-options.md This example demonstrates how to combine multiple request options, including setting client defaults and overriding them for a specific API call. It shows how to configure timeouts, retries, abort signals, custom query parameters, and headers. ```APIDOC ## Complex Request Example Combining multiple request options: ```typescript import { CandidApiClient } from "candidhealth"; const client = new CandidApiClient({ clientId: "...", clientSecret: "...", timeoutInSeconds: 60, // Client default maxRetries: 2 }); const controller = new AbortController(); try { const result = await client.encounters.v4.getAll( { limit: 1000, claimStatus: "biller_received", sort: "created_at:desc" }, { // Override client defaults for this request timeoutInSeconds: 120, maxRetries: 3, abortSignal: controller.signal, // Add request-specific data queryParams: { "include_audit_trail": true }, headers: { "X-Request-ID": "req-" + Date.now(), "X-Custom-Filter": "active" } } ); if (result.ok) { console.log(`Retrieved ${result.body.patients.length} encounters`); } else { console.error("Error:", result.error); } } catch (err) { if (err.name === "AbortError") { console.log("Request was aborted"); } else { throw err; } } ``` ``` -------------------------------- ### Complex Request Example with Options Source: https://github.com/candidhealth/candid-node/blob/master/_autodocs/api-reference/04-request-options.md Demonstrates combining multiple request options such as timeouts, retries, query parameters, and custom headers for a specific API call. This example shows how to override client defaults for a single request and includes an AbortController for request cancellation. ```typescript import { CandidApiClient } from "candidhealth"; const client = new CandidApiClient({ clientId: "...", clientSecret: "...", timeoutInSeconds: 60, // Client default maxRetries: 2 }); const controller = new AbortController(); try { const result = await client.encounters.v4.getAll( { limit: 1000, claimStatus: "biller_received", sort: "created_at:desc" }, { // Override client defaults for this request timeoutInSeconds: 120, maxRetries: 3, abortSignal: controller.signal, // Add request-specific data queryParams: { "include_audit_trail": true }, headers: { "X-Request-ID": "req-" + Date.now(), "X-Custom-Filter": "active" } } ); if (result.ok) { console.log(`Retrieved ${result.body.patients.length} encounters`); } else { console.error("Error:", result.error); } } catch (err) { if (err.name === "AbortError") { console.log("Request was aborted"); } else { throw err; } } ``` -------------------------------- ### client.preEncounter.tags.v1.getAll Source: https://github.com/candidhealth/candid-node/blob/master/reference.md Gets all tags. This operation retrieves a collection of all available tags, with a default page size of 1000. ```APIDOC ## GET /preEncounter/tags/v1 ### Description Gets all tags. Defaults to page size of 1000. ### Method GET ### Endpoint /preEncounter/tags/v1 ### Parameters #### Query Parameters - **request** (CandidApi.preEncounter.tags.v1.GetAllTagsRequest) - Optional - Parameters for filtering or paginating the tag list. - **requestOptions** (V1Client.RequestOptions) - Optional - Options for the request. ### Response #### Success Response (200) - **data** (CandidApi.TagPage) - A page object containing the list of tags. #### Error Response - **error** (CandidApi.preEncounter.tags.v1.getAll.Error) - An error object if retrieving tags fails. ``` -------------------------------- ### Build the Project Source: https://github.com/candidhealth/candid-node/blob/master/CONTRIBUTING.md Execute this command to build the project. ```bash yarn build ``` -------------------------------- ### get Source: https://github.com/candidhealth/candid-node/blob/master/reference.md Gets an image by imageId. ```APIDOC ## get ### Description Gets an image by imageId. ### Method client.preEncounter.images.v1.get ### Parameters #### Path Parameters - **id** (CandidApi.ImageId) - Required - The ID of the image to retrieve. #### Request Options - **requestOptions** (V1Client.RequestOptions) - Optional - Options for the request. ### Request Example ```typescript await client.preEncounter.images.v1.get(CandidApi.ImageId("id")); ``` ### Response #### Success Response (200) - **CandidApi.Image** - The retrieved image object. #### Error Response - **CandidApi.preEncounter.images.v1.get.Error** - Error details. ``` -------------------------------- ### Minimal Example: Making API Calls Source: https://github.com/candidhealth/candid-node/blob/master/_autodocs/README.md Demonstrates how to initialize the client and make various API calls for encounters, eligibility checks, and superbills. Handles successful responses and logs relevant data. ```typescript import { CandidApiClient } from "candidhealth"; const client = new CandidApiClient({ clientId: "your-client-id", clientSecret: "your-client-secret" }); // Get encounters const result = await client.encounters.v4.getAll({ limit: 100 }); if (result.ok) { console.log(`Retrieved ${result.body.encounters.length} encounters`); } // Check eligibility const eligResult = await client.preEncounter.eligibilityChecks.v1.post({ payerId: "aetna", provider: { npi: "1234567890" }, subscriber: { firstName: "Jane", lastName: "Doe" } }); if (eligResult.ok) { console.log(`Eligible: ${eligResult.body.eligible}`); } // Create superbill const sbResult = await client.superbills.v1.create({ encounterId: "encounter-uuid" }); if (sbResult.ok) { console.log(`Superbill created: ${sbResult.body.id}`); } ``` -------------------------------- ### Initialize Client with Custom Configuration Source: https://github.com/candidhealth/candid-node/blob/master/_autodocs/api-reference/01-client-initialization.md Initialize the client with custom settings including environment, timeout, retries, headers, and logging configuration. ```typescript import { CandidApiClient, CandidApiEnvironment, logging } from "candidhealth"; const client = new CandidApiClient({ clientId: "your-client-id", clientSecret: "your-client-secret", environment: CandidApiEnvironment.Staging, timeoutInSeconds: 30, maxRetries: 3, headers: { "X-Custom-Header": "custom-value" }, logging: { level: logging.LogLevel.Debug, logger: new logging.ConsoleLogger(), silent: false } }); ``` -------------------------------- ### Token Endpoint Response (Success) Source: https://github.com/candidhealth/candid-node/blob/master/_autodocs/api-reference/03-authentication.md Example of a successful response from the token endpoint, containing the access token and its expiration time. ```json { "accessToken": "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9...", "expiresIn": 18000 } ``` -------------------------------- ### Get All Tasks V3 Source: https://github.com/candidhealth/candid-node/blob/master/reference.md Fetches a paginated list of all tasks. Can be used without parameters to get the first page. ```typescript await client.tasks.v3.getMulti(); ``` -------------------------------- ### Initializing the Candid API Client Source: https://github.com/candidhealth/candid-node/blob/master/_autodocs/api-reference/01-client-initialization.md Demonstrates how to create an instance of the CandidApiClient and access different resource clients. ```APIDOC ## Client Initialization and Resource Access ### Description The `CandidApiClient` is initialized with credentials and provides access to various API resources through dedicated properties. These properties act as getters, returning initialized client instances for specific domains like `encounters`, `superbills`, or `auth`. ### Usage 1. **Instantiate the client:** ```typescript const client = new CandidApiClient({ clientId: "...", clientSecret: "..." }); ``` 2. **Access resource clients:** Use the getter properties to obtain specific resource clients. ```typescript // Access encounters resource const encountersClient = client.encounters; // Access superbills resource const superbillsClient = client.superbills; // Access auth resource const authClient = client.auth; ``` ### Available Resource Accessors The `CandidApiClient` exposes the following resource accessor properties: - **auth**: For OAuth token generation and management. - **billingNotes**: For billing note creation, update, and deletion. - **chargeCapture**: For charge capture submission and management. - **chargeCaptureBundles**: For charge capture bundle operations. - **contracts**: For healthcare provider contracts. - **credentialing**: For provider credentialing workflows. - **customSchemas**: For custom schema definitions and management. - **diagnoses**: For diagnosis code management. - **eligibility**: For insurance eligibility verification. - **encounterAttachments**: For encounter document attachments. - **encounterProviders**: For provider information within encounters. - **encounterSupplementalInformation**: For additional encounter metadata. - **encounters**: For medical encounter records (primary CRUD operations). - **events**: For event log and audit trail access. - **exports**: For bulk data export operations. - **externalPaymentAccountConfig**: For external payment account configuration. - **feeSchedules**: For procedural fee schedules. - **guarantor**: For guarantor/co-signer information. - **healthCareCodeInformation**: For medical code reference data. - **importInvoice**: For third-party invoice import. - **insuranceAdjudications**: For insurance claim adjudication details. - **insuranceRefunds**: For insurance-side refund management. - **medicationDispense**: For medication dispensing records. - **nonInsurancePayerPayments**: For self-pay and non-insurance payments. - **nonInsurancePayerRefunds**: For non-insurance refund processing. - **nonInsurancePayers**: For self-pay payer management. - **organizationProviders**: For organization provider roster. - **organizationServiceFacilities**: For service facility and location information. - **patientAr**: For patient accounts receivable aging. - **patientPayments**: For patient payment receipt and processing. - **patientRefunds**: For patient refund issuance. - **payerPlanGroups**: For insurance payer plan group mappings. - **payers**: For insurance payer master data. - **preEncounter**: For pre-encounter eligibility and benefits. - **serviceLines**: For individual service line items within claims. - **superbills**: For superbill generation and management. - **tasks**: For task/queue management for staff workflows. - **writeOffs**: For bad debt write-off tracking. ``` -------------------------------- ### Get Eligibility Recommendations Source: https://github.com/candidhealth/candid-node/blob/master/reference.md Gets recommendations for eligibility checks based on filters. This endpoint retrieves the latest eligibility recommendations for each type. ```typescript await client.preEncounter.eligibilityChecks.v1.recommendation(); ``` -------------------------------- ### Get Specific Non-Insurance Payer Refund Source: https://github.com/candidhealth/candid-node/blob/master/reference.md Retrieves a single non-insurance payer refund by its unique identifier. Use this to get details of a specific refund. ```typescript await client.nonInsurancePayerRefunds.v1.get(CandidApi.NonInsurancePayerRefundId("d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32")); ``` -------------------------------- ### Client Initialization Source: https://github.com/candidhealth/candid-node/blob/master/_autodocs/README.md Details on initializing the CandidApiClient, accessing resources, and using the fetch() method for custom endpoints. ```APIDOC ## Client Initialization ### Description Initialize the `CandidApiClient` to interact with the Candid Health API. This involves setting up authentication and accessing various resource clients. ### Class `CandidApiClient` ### Constructor `new CandidApiClient(options: BaseClientOptions)` ### Parameters - **options** (`BaseClientOptions`) - Required - Configuration options for the client, including authentication and environment. ### Resource Accessors - `encounters`: Access the Encounters API. - `superbills`: Access the Superbills API. - `eligibility`: Access the Eligibility API. ### Methods - `fetch(method: string, url: string, options?: RequestOptions): Promise>` - Description: Makes a custom HTTP request to a specified endpoint. - Parameters: - **method** (`string`) - Required - The HTTP method (e.g., 'GET', 'POST'). - **url** (`string`) - Required - The endpoint URL. - **options** (`RequestOptions`) - Optional - Additional request options. - Returns: A promise that resolves with the API response. ``` -------------------------------- ### Get a Paginated List of Coverages Source: https://github.com/candidhealth/candid-node/blob/master/reference.md Retrieves a page of Coverages based on specified search criteria. Call this method without parameters to get the first page of results. ```typescript await client.preEncounter.coverages.v1.getMultiPaginated(); ``` -------------------------------- ### Initialize CandidApiClient and Fetch Encounters Source: https://github.com/candidhealth/candid-node/blob/master/_autodocs/00-START-HERE.txt Demonstrates how to initialize the CandidApiClient with credentials and fetch a list of encounters. Includes basic error handling for the API response. ```typescript import { CandidApiClient } from "candidhealth"; const client = new CandidApiClient({ clientId: "your-client-id", clientSecret: "your-client-secret" }); // Get encounters const result = await client.encounters.v4.getAll({ limit: 100 }); if (result.ok) { console.log(result.body.encounters); } ``` -------------------------------- ### Configure Client with Predefined Environments Source: https://github.com/candidhealth/candid-node/blob/master/_autodocs/configuration.md Instantiate the CandidApiClient using predefined environment constants for Production, Staging, Sandbox, Candid Staging, or Local development. Ensure you provide your client ID and secret. ```typescript import { CandidApiClient, CandidApiEnvironment } from "candidhealth"; // Production (default) new CandidApiClient({ clientId: "...", clientSecret: "...", environment: CandidApiEnvironment.Production }); // Staging new CandidApiClient({ clientId: "...", clientSecret: "...", environment: CandidApiEnvironment.Staging }); // Sandbox new CandidApiClient({ clientId: "...", clientSecret: "...", environment: CandidApiEnvironment.CandidSandbox }); // Candid Staging (alternative) new CandidApiClient({ clientId: "...", clientSecret: "...", environment: CandidApiEnvironment.CandidStaging }); // Local Development new CandidApiClient({ clientId: "...", clientSecret: "...", environment: CandidApiEnvironment.Local }); ``` -------------------------------- ### Submit Eligibility Check (Availity GET) Source: https://github.com/candidhealth/candid-node/blob/master/reference.md Use this endpoint to submit an eligibility check via Availity's GET endpoint. Note that Candid is deprecating support for this endpoint. ```typescript await client.eligibility.v2.submitEligibilityCheckAvaility(); ``` -------------------------------- ### Token Lifecycle Management - Rate Limiting Example Source: https://github.com/candidhealth/candid-node/blob/master/_autodocs/api-reference/03-authentication.md Demonstrates correct and incorrect ways to handle token requests to avoid rate limiting. Reusing the CandidApiClient is recommended as it automatically refreshes tokens. ```APIDOC ## Token Lifecycle Management ### Rate Limiting on Token Endpoint Requesting tokens too frequently triggers HTTP 429 Too Many Requests: ```typescript // WRONG - Requests new token for every API call (gets rate limited) for (let i = 0; i < 100; i++) { const newClient = new CandidApiClient({ clientId: "...", clientSecret: "..." }); await newClient.encounters.v4.getAll({}); } // RIGHT - Reuse same client (tokens are automatically refreshed) const client = new CandidApiClient({ clientId: "...", clientSecret: "..." }); for (let i = 0; i < 100; i++) { await client.encounters.v4.getAll({}); } ``` ``` -------------------------------- ### client.preEncounter.patients.v1.get Source: https://github.com/candidhealth/candid-node/blob/master/reference.md Gets a patient by their ID. ```APIDOC ## get ### Description Gets a patient by their ID. ### Method GET ### Endpoint /preEncounter/patients/v1/{id} ### Parameters #### Path Parameters - **id** (CandidApi.PatientId) - Required - The ID of the patient to retrieve. #### Query Parameters - **requestOptions** (V1Client.RequestOptions) - Optional - Request options. ### Response #### Success Response (200) - **data** (CandidApi.Patient) - The requested patient object. - **errors** (CandidApi.preEncounter.patients.v1.get.Error) - Errors encountered during the retrieval. ``` -------------------------------- ### client.preEncounter.coverages.v1.get Source: https://github.com/candidhealth/candid-node/blob/master/reference.md Gets a specific Coverage by its ID. ```APIDOC ## get ### Description Gets a specific Coverage by its ID. ### Method GET ### Endpoint /preEncounter/coverages/v1/{id} ### Parameters #### Path Parameters - **id** (CandidApi.CoverageId) - Required - The ID of the coverage to retrieve. #### Request Options - **requestOptions** (V1Client.RequestOptions) - Optional - Options for the request. ### Response #### Success Response (200) - **coverage** (CandidApi.Coverage) - The requested coverage object. #### Response Example ```json { "id": "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32", "version": 1, "status": "ACTIVE", "subscriber": { "name": { "family": "family", "given": ["given", "given"], "use": "USUAL" }, "biologicalSex": "FEMALE" }, "relationship": "SELF", "patient": "patient_id", "insurancePlan": { "memberId": "member_id", "payerId": "payer_id", "payerName": "payer_name" }, "verified": true, "createdAt": "timestamp", "updatedAt": "timestamp" } ``` ``` -------------------------------- ### Initialize Client with Client Credentials Source: https://github.com/candidhealth/candid-node/blob/master/_autodocs/api-reference/03-authentication.md Instantiate the CandidApiClient with your client ID and secret for automatic token management. The SDK handles token acquisition and refresh in the background. ```typescript import { CandidApiClient } from "candidhealth"; const client = new CandidApiClient({ clientId: "your-client-id", clientSecret: "your-client-secret" }); // Token is automatically acquired and refreshed as needed await client.encounters.v4.getAll({}); ``` -------------------------------- ### getPayerThresholdsDefault Source: https://github.com/candidhealth/candid-node/blob/master/reference.md Gets the default payer threshold. ```APIDOC ## getPayerThresholdsDefault ### Description Gets the default payer threshold. ### Method GET ### Endpoint /fee-schedules/v3/payer-thresholds/default ### Parameters #### Query Parameters - **requestOptions** (V3Client.RequestOptions) - Optional - Options for the request. ### Response #### Success Response (200) - **payerThreshold** (CandidApi.PayerThreshold) - The default payer threshold object. #### Response Example ```json { "someField": "someValue" } ``` ### Error Handling - **CandidApi.feeSchedules.v3.getPayerThresholdsDefault.Error** - Details about the error if retrieval fails. ``` -------------------------------- ### Initialize Client and Access Resources Source: https://github.com/candidhealth/candid-node/blob/master/_autodocs/api-reference/01-client-initialization.md Demonstrates initializing the CandidApiClient with credentials and accessing different resource clients via their getter properties. This pattern applies to all available API resources. ```typescript const client = new CandidApiClient({ clientId: "...", clientSecret: "..." }); // Access encounters resource const encountersClient = client.encounters; // Access superbills resource const superbillsClient = client.superbills; // All resource accessors follow this pattern const authClient = client.auth; ``` -------------------------------- ### Configure CandidApiClient with ConsoleLogger Source: https://github.com/candidhealth/candid-node/blob/master/_autodocs/api-reference/05-logging.md Example of initializing the CandidApiClient with custom logging configuration, specifying the log level and using ConsoleLogger. Ensure 'silent' is set to false to enable logging. ```typescript import { CandidApiClient, logging } from "candidhealth"; const client = new CandidApiClient({ clientId: "...", clientSecret: "...", logging: { level: logging.LogLevel.Debug, logger: new logging.ConsoleLogger(), silent: false // Enable logging } }); ``` -------------------------------- ### client.feeSchedules.v3.getRateHistory Source: https://github.com/candidhealth/candid-node/blob/master/reference.md Gets every version of a rate. ```APIDOC ## client.feeSchedules.v3.getRateHistory ### Description Gets every version of a rate. ### Method GET ### Endpoint /fee-schedules/v3/rates/{rate_id}/history ### Parameters #### Path Parameters - **rate_id** (CandidApi.RateId) - Required - The ID of the rate for which to retrieve history. #### Query Parameters - **requestOptions** (V3Client.RequestOptions) - Optional - Options for the request, such as headers or timeouts. ``` -------------------------------- ### client.tasks.v3.create Source: https://github.com/candidhealth/candid-node/blob/master/reference.md Creates a new task. ```APIDOC ## create ### Description Creates a new task. ### Method POST ### Endpoint /tasks/v3 ### Parameters #### Request Body - **encounterId** (string) - Required - The ID of the encounter. - **taskType** (string) - Required - The type of the task. - **description** (string) - Optional - A description of the task. - **workQueueId** (string) - Required - The ID of the work queue. ### Request Example ```json { "encounterId": "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32", "taskType": "CUSTOMER_DATA_REQUEST", "description": "description", "workQueueId": "work_queue_id" } ``` ### Response #### Success Response (200) - **id** (string) - The unique identifier for the created task. - **encounter_id** (string) - The ID of the encounter associated with the task. - **task_type** (string) - The type of the task. - **status** (string) - The current status of the task. - **created_at** (string) - The timestamp when the task was created. - **updated_at** (string) - The timestamp when the task was last updated. #### Response Example ```json { "id": "string", "encounter_id": "string", "task_type": "string", "status": "string", "created_at": "string", "updated_at": "string" } ``` ``` -------------------------------- ### get Source: https://github.com/candidhealth/candid-node/blob/master/reference.md Retrieves a previously created write off by its `write_off_id`. ```APIDOC ## GET /writeOffs/v1/{write_off_id} ### Description Retrieves a previously created write off by its `write_off_id`. ### Method GET ### Endpoint /writeOffs/v1/{write_off_id} ### Parameters #### Path Parameters - **write_off_id** (CandidApi.WriteOffId) - Required - The ID of the write-off to retrieve. #### Query Parameters - **requestOptions** (V1Client.RequestOptions) - Optional - Options for the request. ### Response #### Success Response (200) - **data** (CandidApi.WriteOff) - The requested write-off record. #### Error Response - **error** (CandidApi.writeOffs.v1.get.Error) - Details about the error. ``` -------------------------------- ### Minimal Candid API Client Setup Source: https://github.com/candidhealth/candid-node/blob/master/_autodocs/api-reference/11-usage-patterns.md Initialize the Candid API client with essential credentials. Ensure client ID and secret are provided, typically via environment variables. ```typescript import { CandidApiClient } from "candidhealth"; const client = new CandidApiClient({ clientId: process.env.CANDID_CLIENT_ID || "", clientSecret: process.env.CANDID_CLIENT_SECRET || "" }); // Make API calls const result = await client.encounters.v4.getAll({ limit: 100 }); ``` -------------------------------- ### get() Source: https://github.com/candidhealth/candid-node/blob/master/_autodocs/api-reference/07-encounters.md Retrieve a single encounter by its unique identifier. ```APIDOC ## get() - Retrieve Encounter ### Description Retrieve a single encounter by ID. ### Method `get` ### Parameters #### Path Parameters - **encounterId** (EncounterId) - Required - UUID of the encounter to retrieve - **requestOptions** (BaseRequestOptions) - Optional - SDK request options ### Response #### Success Response - **body** (APIResponse) - Promise returning the full encounter record. ### Request Example ```typescript const result = await client.encounters.v4.get( CandidApi.EncounterId("d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32") ); if (result.ok) { const encounter = result.body; console.log(`Encounter for patient: ${encounter.patientId}`); console.log(`Service date: ${encounter.dateOfService}`); } else { console.error("Encounter not found or error:", result.error); } ``` ``` -------------------------------- ### create Source: https://github.com/candidhealth/candid-node/blob/master/reference.md Creates a new organization service facility. ```APIDOC ## POST Create Organization Service Facility ### Description Creates a new organization service facility with the provided details. ### Method POST ### Endpoint `/organizationServiceFacilities/v2` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **request** (CandidApi.OrganizationServiceFacilityCreate) - Required - The details for the new organization service facility. - **name** (string) - Required - The name of the service facility. - **aliases** (string[]) - Optional - A list of aliases for the service facility. - **description** (string) - Optional - A description of the service facility. - **status** (string) - Required - The status of the service facility (e.g., "active"). - **operationalStatus** (string) - Required - The operational status of the service facility (e.g., "C"). - **mode** (string) - Required - The mode of the service facility (e.g., "instance"). - **type** (string) - Required - The type of the service facility (e.g., "DX"). - **physicalType** (string) - Required - The physical type of the service facility (e.g., "si"). - **telecoms** (string[]) - Optional - A list of telecommunication numbers for the service facility. - **address** (object) - Optional - The address of the service facility. - **address1** (string) - Required - The first line of the address. - **address2** (string) - Optional - The second line of the address. - **city** (string) - Required - The city. - **state** (string) - Required - The state. - **zipCode** (string) - Required - The zip code. - **zipPlusFourCode** (string) - Optional - The zip+4 code. ### Request Example ```json { "name": "Test Service Facility", "aliases": ["Test Service Facility Alias"], "description": "Test Service Facility Description", "status": "active", "operationalStatus": "C", "mode": "instance", "type": "DX", "physicalType": "si", "telecoms": ["555-555-5555"], "address": { "address1": "123 Main St", "address2": "Apt 1", "city": "New York", "state": "NY", "zipCode": "10001", "zipPlusFourCode": "1234" } } ``` ### Response #### Success Response (200) - **organizationServiceFacility** (CandidApi.OrganizationServiceFacility) - The newly created organization service facility object. #### Error Response - **error** (CandidApi.organizationServiceFacilities.v2.create.Error) - Details about the error if the creation fails. ``` -------------------------------- ### Run Test Suite Source: https://github.com/candidhealth/candid-node/blob/master/CONTRIBUTING.md This command runs the entire test suite for the project. ```bash yarn test ``` -------------------------------- ### client.preEncounter.patients.v1.getByMrn Source: https://github.com/candidhealth/candid-node/blob/master/reference.md Gets a patient by their Medical Record Number (MRN). ```APIDOC ## getByMrn ### Description Gets a patient by their Medical Record Number (MRN). ### Method GET ### Endpoint /preEncounter/patients/v1/byMrn/{mrn} ### Parameters #### Path Parameters - **mrn** (string) - Required - The MRN of the patient to retrieve. #### Query Parameters - **requestOptions** (V1Client.RequestOptions) - Optional - Request options. ### Response #### Success Response (200) - **data** (CandidApi.Patient) - The requested patient object. - **errors** (CandidApi.preEncounter.patients.v1.getByMrn.Error) - Errors encountered during the retrieval. ``` -------------------------------- ### get Source: https://github.com/candidhealth/candid-node/blob/master/reference.md Retrieves a previously created patient refund by its `patient_refund_id`. ```APIDOC ## GET /patientRefunds/v1/{patient_refund_id} ### Description Retrieves a previously created patient refund by its `patient_refund_id`. ### Method GET ### Endpoint /patientRefunds/v1/{patient_refund_id} ### Parameters #### Path Parameters - **patient_refund_id** (CandidApi.PatientRefundId) - Required - The ID of the patient refund to retrieve. #### Query Parameters - **requestOptions** (V1Client.RequestOptions) - Optional - Options for the request, such as headers or timeouts. ### Response #### Success Response (200) - **data** (CandidApi.PatientRefund) - The requested patient refund object. - **errors** (CandidApi.patientRefunds.v1.get.Error) - Errors encountered during the operation. ``` -------------------------------- ### Configure Client with Custom Environment URLs Source: https://github.com/candidhealth/candid-node/blob/master/_autodocs/configuration.md Instantiate the CandidApiClient with custom environment URLs for the primary API and pre-encounter services. This is useful for connecting to self-hosted or non-standard API endpoints. ```typescript new CandidApiClient({ clientId: "...", clientSecret: "...", environment: { candidApi: "https://custom-api.example.com", preEncounter: "https://custom-pre.example.com" } }); ``` -------------------------------- ### get Source: https://github.com/candidhealth/candid-node/blob/master/reference.md Retrieves a single organization service facility by its ID. ```APIDOC ## GET Organization Service Facility by ID ### Description Retrieves a single organization service facility using its unique identifier. ### Method GET ### Endpoint `/organizationServiceFacilities/v2/{organization_service_facility_id}` ### Parameters #### Path Parameters - **organization_service_facility_id** (CandidApi.OrganizationServiceFacilityId) - Required - The ID of the organization service facility to retrieve. #### Request Body None ### Response #### Success Response (200) - **organizationServiceFacility** (CandidApi.OrganizationServiceFacility) - The retrieved organization service facility object. #### Error Response - **error** (CandidApi.organizationServiceFacilities.v2.get.Error) - Details about the error if the retrieval fails. ``` -------------------------------- ### Get Organization Provider Source: https://github.com/candidhealth/candid-node/blob/master/reference.md Retrieves a specific organization provider by its ID. ```APIDOC ## Get Organization Provider ### Description Retrieves a specific organization provider by its ID. ### Method GET ### Endpoint /organization-providers/{organization_provider_id} ### Parameters #### Path Parameters - **organization_provider_id** (CandidApi.OrganizationProviderId) - Required - The ID of the organization provider to retrieve. #### Request Example ```typescript await client.organizationProviders.v3.get(CandidApi.OrganizationProviderId("965A563A-0285-4910-9569-E3739C0F6EAB")); ``` ### Response #### Success Response (200) - **organizationProvider** (CandidApi.OrganizationProviderV2) - The retrieved organization provider details. #### Error Response - **error** (CandidApi.organizationProviders.v3.get.Error) - Details about the error. ``` -------------------------------- ### List Claims with Claims API Source: https://github.com/candidhealth/candid-node/blob/master/_autodocs/api-reference/10-additional-resources.md Use the `getAll` method to retrieve a list of claims, filtering by status. This example demonstrates fetching up to 100 approved claims and logging their IDs and statuses. ```typescript const result = await client.claims.v1.getAll({ limit: 100, claimStatus: "approved" }); if (result.ok) { result.body.claims.forEach(claim => { console.log(`Claim ${claim.id}: ${claim.status}`); }); } ``` -------------------------------- ### Get Default Payer Thresholds Source: https://github.com/candidhealth/candid-node/blob/master/reference.md Retrieves the default payer threshold settings. ```typescript await client.feeSchedules.v3.getPayerThresholdsDefault(); ``` -------------------------------- ### OAuthAuthProvider - Client Credentials Flow Source: https://github.com/candidhealth/candid-node/blob/master/_autodocs/api-reference/03-authentication.md The SDK automatically handles token acquisition and refresh when you provide clientId and clientSecret. This example demonstrates how to initialize the CandidApiClient with these credentials. ```APIDOC ## Creating with Client Credentials Flow The SDK automatically handles token acquisition and refresh when you provide clientId and clientSecret: ```typescript import { CandidApiClient } from "candidhealth"; const client = new CandidApiClient({ clientId: "your-client-id", clientSecret: "your-client-secret" }); // Token is automatically acquired and refreshed as needed await client.encounters.v4.getAll({}); ``` ### Parameters for Client Credentials #### Path Parameters This section is not applicable for this operation. #### Query Parameters This section is not applicable for this operation. #### Request Body This section is not applicable for this operation. ### Request Example This section is not applicable for this operation. ### Response This section is not applicable for this operation. #### Success Response (200) This section is not applicable for this operation. #### Response Example This section is not applicable for this operation. ``` -------------------------------- ### Get All Facility Credentialing Source: https://github.com/candidhealth/candid-node/blob/master/reference.md Retrieves a paginated list of all facility credentialing spans. ```typescript await client.credentialing.v2.getAllFacilities(); ``` -------------------------------- ### CandidApiClient Constructor Source: https://github.com/candidhealth/candid-node/blob/master/_autodocs/api-reference/01-client-initialization.md Instantiate the CandidApiClient with authentication credentials and configuration options to access all API resources. The constructor requires an options object that can include client ID, client secret, a pre-generated token, environment settings, custom headers, timeouts, retry configurations, a custom fetch implementation, and logging settings. ```APIDOC ## CandidApiClient Constructor ### Description Instantiate the main entry point for the Candid Health API SDK. This client is used to access all API resources. ### Method `constructor` ### Parameters #### Options Object - **options** (CandidApiClient.Options) - Required - Configuration object for client initialization. - **clientId** (string | Supplier) - Conditional - OAuth 2.0 client ID (required if not using token). - **clientSecret** (string | Supplier) - Conditional - OAuth 2.0 client secret (required if not using token). - **token** (string | Supplier) - Conditional - Pre-generated bearer token (alternative to clientId/clientSecret). - **environment** (Supplier) - Optional - API environment to use. Defaults to Production. - **baseUrl** (Supplier) - Optional - Custom base URL for API requests. - **headers** (Record | null | undefined>) - Optional - Additional headers to include in all requests. Defaults to {}. - **timeoutInSeconds** (number) - Optional - Default timeout for all requests in seconds. Defaults to 60. - **maxRetries** (number) - Optional - Default maximum retry attempts for retryable requests. Defaults to 2. - **fetch** (typeof fetch) - Optional - Custom fetch implementation for advanced use cases. - **logging** (LogConfig | Logger) - Optional - Logging configuration for request/response logging. Defaults to Silent. ### Throws - `CandidApiError` - Thrown if neither clientId/clientSecret nor token is provided. ### Examples **OAuth Client Credentials Flow:** ```typescript import { CandidApiClient } from "candidhealth"; const client = new CandidApiClient({ clientId: "your-client-id", clientSecret: "your-client-secret", }); ``` **Token Override (pre-generated bearer token):** ```typescript import { CandidApiClient } from "candidhealth"; const client = new CandidApiClient({ token: "your-bearer-token", }); ``` **With Custom Configuration:** ```typescript import { CandidApiClient, CandidApiEnvironment, logging } from "candidhealth"; const client = new CandidApiClient({ clientId: "your-client-id", clientSecret: "your-client-secret", environment: CandidApiEnvironment.Staging, timeoutInSeconds: 30, maxRetries: 3, headers: { "X-Custom-Header": "custom-value" }, logging: { level: logging.LogLevel.Debug, logger: new logging.ConsoleLogger(), silent: false } }); ``` ``` -------------------------------- ### Get Facility Credentialing Source: https://github.com/candidhealth/candid-node/blob/master/reference.md Retrieves a specific facility credentialing span by its ID. ```typescript await client.credentialing.v2.getFacility(CandidApi.FacilityCredentialingSpanId("d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32")); ``` -------------------------------- ### create() Source: https://github.com/candidhealth/candid-node/blob/master/_autodocs/api-reference/07-encounters.md Create a new encounter record with provided details. ```APIDOC ## create() - Create Encounter ### Description Create a new encounter record. ### Method `create` ### Parameters #### Request Body - **request** (EncounterCreate) - Required - Encounter data to create - **request.patientId** (string) - Required - UUID of the patient - **request.dateOfService** (string (ISO 8601)) - Required - Date of service (YYYY-MM-DD) - **request.provider** (ProviderInfo) - Optional - Primary provider information - **request.billableStatus** (BillableStatusType) - Optional - Initial billable status - **request.tagIds** (string[]) - Optional - Associated tag IDs - **request.externalId** (string) - Optional - External system ID for this encounter - **requestOptions** (BaseRequestOptions) - Optional - SDK request options ### Response #### Success Response - **body** (APIResponse) - Promise returning the created encounter with assigned ID. ### Request Example ```typescript const result = await client.encounters.v4.create({ patientId: "patient-uuid-123", dateOfService: "2024-06-15", provider: { npi: "1234567890", firstName: "John", lastName: "Smith" }, billableStatus: "unbillable", externalId: "ENC-2024-001" }); if (result.ok) { console.log(`Created encounter: ${result.body.id}`); } else { console.error("Error creating encounter:", result.error.content); } ``` ``` -------------------------------- ### Retrieve Encounters with Filtering and Pagination Source: https://github.com/candidhealth/candid-node/blob/master/_autodocs/api-reference/07-encounters.md Use the `getAll` method to fetch a paginated list of encounters. You can filter by claim status, date range, payer names, and sort the results. The example demonstrates fetching encounters within a specific date range and with a particular claim status. ```typescript public getAll( request?: CandidApi.encounters.v4.GetAllEncountersRequest, requestOptions?: V4Client.RequestOptions ): core.HttpResponsePromise< core.APIResponse > ``` ```typescript const result = await client.encounters.v4.getAll({ limit: 100, claimStatus: "biller_received", sort: "created_at:desc", dateOfServiceMin: "2024-01-01", dateOfServiceMax: "2024-12-31", primaryPayerNames: "Medicare,Blue Cross" }); if (result.ok) { const encounters = result.body.encounters; console.log(`Retrieved ${encounters.length} encounters`); // Fetch next page if available if (result.body.pageToken) { const nextPage = await client.encounters.v4.getAll({ limit: 100, pageToken: result.body.pageToken }); } } else { console.error("Error retrieving encounters:", result.error.content); } ``` ``` -------------------------------- ### Get Patient by ID Source: https://github.com/candidhealth/candid-node/blob/master/reference.md Retrieves a specific patient record using their unique identifier. ```typescript await client.preEncounter.patients.v1.get(CandidApi.PatientId("id")); ``` -------------------------------- ### Get PreEncounter Image V1 Source: https://github.com/candidhealth/candid-node/blob/master/reference.md Retrieves an image by its ID. Requires a valid CandidApi.ImageId. ```typescript await client.preEncounter.images.v1.get(CandidApi.ImageId("id")); ``` -------------------------------- ### client.guarantor.v1.create Source: https://github.com/candidhealth/candid-node/blob/master/reference.md Creates a new guarantor and returns the newly created Guarantor object. It requires an encounter ID and guarantor details. ```APIDOC ## client.guarantor.v1.create ### Description Creates a new guarantor and returns the newly created Guarantor object. ### Method POST (inferred from create operation) ### Endpoint /guarantors/v1 ### Parameters #### Path Parameters - None #### Query Parameters - None #### Request Body - **encounter_id** (CandidApi.EncounterId) - Required - The ID of the encounter associated with the guarantor. - **request** (CandidApi.GuarantorCreate) - Required - The data for creating the guarantor. - **firstName** (string) - Required - The first name of the guarantor. - **lastName** (string) - Required - The last name of the guarantor. - **externalId** (string) - Optional - An external identifier for the guarantor. - **address** (object) - Optional - The address of the guarantor. - **address1** (string) - Required - The first line of the address. - **city** (string) - Required - The city. - **state** (string) - Required - The state (e.g., 'AA'). - **zipCode** (string) - Required - The zip code. - **requestOptions** (V1Client.RequestOptions) - Optional - Options for the request. ### Request Example ```json { "encounter_id": "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32", "request": { "firstName": "first_name", "lastName": "last_name", "externalId": "external_id", "address": { "address1": "address1", "city": "city", "state": "AA", "zipCode": "zip_code" } } } ``` ### Response #### Success Response (200) - **Guarantor** (object) - The newly created guarantor object. - **id** (string) - The unique identifier for the guarantor. - **firstName** (string) - The first name of the guarantor. - **lastName** (string) - The last name of the guarantor. - **externalId** (string) - An external identifier for the guarantor. - **address** (object) - The address of the guarantor. - **address1** (string) - The first line of the address. - **city** (string) - The city. - **state** (string) - The state. - **zipCode** (string) - The zip code. - **createdAt** (string) - The timestamp when the guarantor was created. - **updatedAt** (string) - The timestamp when the guarantor was last updated. #### Response Example ```json { "id": "generated-guarantor-id", "firstName": "first_name", "lastName": "last_name", "externalId": "external_id", "address": { "address1": "address1", "city": "city", "state": "AA", "zipCode": "zip_code" }, "createdAt": "2023-10-27T10:00:00Z", "updatedAt": "2023-10-27T10:00:00Z" } ``` ```