@health-samurai/aidbox-client
    Preparing search index...

    Class AidboxClient<TBundle, TOperationOutcome, TUser>

    Create a client to the FHIR server.

    import type { User } from "@health-samurai/aidbox-client";

    const baseUrl = "https://fhir-server.address";
    const client = new AidboxClient(
    baseUrl,
    new BrowserAuthProvider(baseUrl);
    );

    // alternatively, specify different FHIR types:
    import type { Bundle, OperationOutcome } from "hl7-fhir-r5-core";
    const client = new AidboxClient<Bundle, OperationOutcome, User>(
    baseUrl,
    authProvider: new BrowserAuthProvider(baseUrl);
    );

    Main client functions are request for typed interactions, and rawRequest for manual response processing.

    This client also provides a set of convenience methods for accessing FHIR operations, provided below.

    Type Parameters

    Index

    Instance Level Interactions

    Type Level Interactions

    Whole System Interactions

    Compartment Interactions

    Operations

    Aidbox methods

    • Execute a raw SQL query against the Aidbox database.

      The interaction is performed by an HTTP POST command as shown:

      POST [base]/$sql
      

      Example usage:

      Important: Always use parameterized queries to prevent SQL injection. Pass user-supplied values via params, never interpolate them into the query string.

      // Good — parameterized
      const result = await client.sql<{ cnt: number }>(
      "SELECT count(*) as cnt FROM patient WHERE id = ?", [patientId]
      );

      // Bad — SQL injection risk
      const result = await client.sql(`SELECT * FROM patient WHERE id = '${patientId}'`);

      Note: $sql is an Aidbox-specific endpoint (not part of the FHIR spec). The URL uses the Aidbox-native prefix (/$sql), not the FHIR prefix (/fhir/$sql).

      Type Parameters

      • T

      Parameters

      • query: string
      • Optionalparams: (string | number | boolean | null)[]

      Returns Promise<Result<ResourceResponse<T[]>, ResourceResponse<TOperationOutcome>>>

    Client methods

    Constructors

    Properties

    baseUrl: string
    authProvider: AuthProvider