Options
All
  • Public
  • Public/Protected
  • All
Menu

Additional options that can be passed to client.request to control its behavior

Hierarchy

  • FhirOptions

Index

Properties

flat?: boolean

When fetching a Bundle, you are typically only interested in the included resources which are located at {response}.entry[N].resource. If this option is set to true, the returned result will be an array of resources instead of the whole bundle. This is especially useful when multiple pages are fetched, because an array of page bundles is not that useful and will often have to be converted to array of resources that is easier to iterate.

  • This option is ignored if the response is not a bundle.
  • If you use onPage callback with flat: true, it will receive that array of resources instead of the page bundle.
  • Resources from multiple pages are flattened into single array (unless you use onPage, which will be called with one array for each page).
  • Defaults to false.
  • Finally, Bundle.entry is optional in FHIR and that leads to bugs in apps that assume that it is always present. With flat: true, you will always get an array, even if it is empty, and even if no entry is found in the response bundle.
graph?: boolean

Only applicable if you use resolveReferences. If false, the resolved references will not be "mounted" in the result tree, but will be returned as separate map object instead. Defaults to true.

pageLimit?: number

When you request a Bundle, the result will typically come back in pages and you will only get the first page. You can use pageLimit greater than 1 to request multiple pages. For example pageLimit: 3 will fetch the first 3 pages as array. To fetch all the available pages you can set this to 0.

  • Defaults to 1.
  • Ignored if the response is not a Bundle.
resolveReferences?: string | string[]

One or more references to resolve. Single item can be specified as a string or as an array of one string. Multiple items must be specified as array.

  • Each item is a dot-separated path to the desired reference within the result object, excluding the "reference" property. For example context.serviceProvider will look for {Response}.context.serviceProvider.reference.
  • If the target is an array of references (E.g. Patient.generalPractitioner), you can request one or more of them by index (E.g. generalPractitioner.0). If the index is not specified, all the references in the array will be resolved.
  • The order in which the reference paths are specified does not matter. For example, if you use ["subject", "encounter.serviceProvider", "encounter"], the library should figure out that encounter.serviceProvider must be fetched after encounter. In fact, in this case it will first fetch subject and encounter in parallel, and then proceed to encounter.serviceProvider.
  • This option does not work with contained references (they are "already resolved" anyway).
useRefreshToken?: boolean

If the client is authorized, it will possess an access token and pass it with the requests it makes. When that token expires, you should get back a 401 Unauthorized response. When that happens, if the client also has a refresh token and if useRefreshToken is true (default), the client will attempt to automatically re-authorize itself and then it will re-run the failed request and eventually resolve it's promise with the final result. This means that your requests should never fail with 401, unless the refresh token is also expired. If you don't want this, you can set useRefreshToken to false. There is a refresh method on the client that can be called manually to renew the access token.

  • Defaults to true.

Methods

  • When you fetch multiple pages the resulting array may be very large, requiring a lot of time and memory. It is often better if you specify a page callback instead. The onPage callback will be called once for each page with the page Bundle as it's argument. If you use resolveReferences and graph: false, the references will be passed to onPage as second argument.

    • If onPage returns a promise it will be awaited for, meaning that no more pages will be fetched until the onPage promise is resolved.
    • If onPage returns a rejected promise or throws an error, the client will not continue fetching more pages.
    • If you use onPage callback, the promise returned by request() will be resolved with null. This is to avoid building that huge array in memory. By using the onPage option you are stating that you will handle the result one page at a time, instead of expecting to receive the big combined result.

    Parameters

    • data: JsonObject | JsonObject[]

      Depending in the other options can be Bundle, Bundle[], Resource[]

    • Optional references: JsonObject

      Map of resolved references. Only available if the graph option is set to false

    Returns any

Generated using TypeDoc