Skip to main content

Interface: MedplumClientOptions

The MedplumClientOptions interface defines configuration options for MedplumClient.

All configuration settings are optional.

Properties

baseUrl

Optional baseUrl: string

Base server URL.

Default value is https://api.medplum.com/

Use this to point to a custom Medplum deployment.

Defined in

packages/core/src/client.ts:99


authorizeUrl

Optional authorizeUrl: string

OAuth2 authorize URL.

Default value is baseUrl + "/oauth2/authorize".

Can be specified as absolute URL or relative to baseUrl.

Use this if you want to use a separate OAuth server.

Defined in

packages/core/src/client.ts:110


fhirUrlPath

Optional fhirUrlPath: string

FHIR URL path.

Default value is "fhir/R4/".

Can be specified as absolute URL or relative to baseUrl.

Use this if you want to use a different path when connecting to a FHIR server.

Defined in

packages/core/src/client.ts:121


tokenUrl

Optional tokenUrl: string

OAuth2 token URL.

Default value is baseUrl + "/oauth2/token".

Can be specified as absolute URL or relative to baseUrl.

Use this if you want to use a separate OAuth server.

Defined in

packages/core/src/client.ts:132


logoutUrl

Optional logoutUrl: string

OAuth2 logout URL.

Default value is baseUrl + "/oauth2/logout".

Can be specified as absolute URL or relative to baseUrl.

Use this if you want to use a separate OAuth server.

Defined in

packages/core/src/client.ts:143


clientId

Optional clientId: string

The client ID.

Client ID can be used for SMART-on-FHIR customization.

Defined in

packages/core/src/client.ts:150


clientSecret

Optional clientSecret: string

The client secret.

Client secret can be used for FHIR Oauth Client Credential flows

Defined in

packages/core/src/client.ts:157


accessToken

Optional accessToken: string

The OAuth Access Token.

Access Token used to connect to make request to FHIR servers

Defined in

packages/core/src/client.ts:164


resourceCacheSize

Optional resourceCacheSize: number

Number of resources to store in the cache.

Default value is 1000.

Consider using this for performance of displaying Patient or Practitioner resources.

Defined in

packages/core/src/client.ts:173


cacheTime

Optional cacheTime: number

The length of time in milliseconds to cache resources.

Default value is 10000 (10 seconds).

Cache time of zero disables all caching.

For any individual request, the cache behavior can be overridden by setting the cache property on request options.

See: https://developer.mozilla.org/en-US/docs/Web/API/Request/cache

Defined in

packages/core/src/client.ts:186


autoBatchTime

Optional autoBatchTime: number

The length of time in milliseconds to delay requests for auto batching.

Auto batching attempts to group multiple requests together into a single batch request.

Default value is 0, which disables auto batching.

Defined in

packages/core/src/client.ts:195


fetch

Optional fetch: FetchLike

Fetch implementation.

Default is window.fetch (if available).

For Node.js applications, consider the 'node-fetch' package.

Defined in

packages/core/src/client.ts:204


storage

Optional storage: ClientStorage

Storage implementation.

Default is window.localStorage (if available), this is the common implementation for use in the browser, or an in-memory storage implementation. If using Medplum on a server it may be useful to provide a custom storage implementation, for example using redis, a database or a file based storage. Medplum CLI is an an example of FileSystemStorage, for reference.

Defined in

packages/core/src/client.ts:211


createPdf

Optional createPdf: CreatePdfFunction

Create PDF implementation.

Default is none, and PDF generation is disabled.

In browser environments, import the client-side pdfmake library.

<script src="pdfmake.min.js"></script>
<script>
async function createPdf(docDefinition, tableLayouts, fonts) {
return new Promise((resolve) => {
pdfMake.createPdf(docDefinition, tableLayouts, fonts).getBlob(resolve);
});
}
</script>

In Node.js applications:

import type { CustomTableLayout, TDocumentDefinitions, TFontDictionary } from 'pdfmake/interfaces';
function createPdf(
docDefinition: TDocumentDefinitions,
tableLayouts?: { [name: string]: CustomTableLayout },
fonts?: TFontDictionary
): Promise<Buffer> {
return new Promise((resolve, reject) => {
const printer = new PdfPrinter(fonts ?? {});
const pdfDoc = printer.createPdfKitDocument(docDefinition, { tableLayouts });
const chunks: Uint8Array[] = [];
pdfDoc.on('data', (chunk: Uint8Array) => chunks.push(chunk));
pdfDoc.on('end', () => resolve(Buffer.concat(chunks)));
pdfDoc.on('error', reject);
pdfDoc.end();
});
}

Defined in

packages/core/src/client.ts:252


onUnauthenticated

Optional onUnauthenticated: () => void

Type declaration

▸ (): void

Callback for when the client is unauthenticated.

Default is do nothing.

For client side applications, consider redirecting to a sign in page.

Returns

void

Defined in

packages/core/src/client.ts:261


redirect

Optional redirect: RequestRedirect

The default redirect behavior.

The default behavior is to not follow redirects.

Use "follow" to automatically follow redirects.

Defined in

packages/core/src/client.ts:270


verbose

Optional verbose: boolean

When the verbose flag is set, the client will log all requests and responses to the console.

Defined in

packages/core/src/client.ts:275