Options
All
  • Public
  • Public/Protected
  • All
Menu

Index

Variables

debug: any = ...
units: { any: any; cm: any; kg: any } = ...

A namespace with functions for converting between different measurement units

Type declaration

Other Functions

  • absolute(path: string, baseUrl?: string): string
  • Given a path, converts it to absolute url based on the baseUrl. If baseUrl is not provided, the result would be a rooted path (one that starts with /).

    Parameters

    • path: string

      The path to convert

    • Optional baseUrl: string

      The base URL

    Returns string

  • assert(condition: any, message: string): asserts condition
  • Parameters

    • condition: any
    • message: string

    Returns asserts condition

  • assertJsonPatch(patch: JsonPatch): asserts patch
  • Groups the observations by code. Returns a map that will look like:

    const map = client.byCodes(observations, "code");
    // map = {
    // "55284-4": [ observation1, observation2 ],
    // "6082-2": [ observation3 ]
    // }

    Parameters

    • observations: Observation | Observation[]

      Array of observations

    • property: string

      The name of a CodeableConcept property to group by

    Returns ObservationMap

  • First groups the observations by code using byCode. Then returns a function that accepts codes as arguments and will return a flat array of observations having that codes. Example:

    const filter = client.byCodes(observations, "category");
    filter("laboratory") // => [ observation1, observation2 ]
    filter("vital-signs") // => [ observation3 ]
    filter("laboratory", "vital-signs") // => [ observation1, observation2, observation3 ]

    Parameters

    • observations: Observation | Observation[]

      Array of observations

    • property: string

      The name of a CodeableConcept property to group by

    Returns (...codes: string[]) => any[]

      • (...codes: string[]): any[]
      • First groups the observations by code using byCode. Then returns a function that accepts codes as arguments and will return a flat array of observations having that codes. Example:

        const filter = client.byCodes(observations, "category");
        filter("laboratory") // => [ observation1, observation2 ]
        filter("vital-signs") // => [ observation3 ]
        filter("laboratory", "vital-signs") // => [ observation1, observation2, observation3 ]

        Parameters

        • Rest ...codes: string[]

        Returns any[]

  • checkResponse(resp: Response): Promise<Response>
  • Used in fetch Promise chains to reject if the "ok" property is not true

    Parameters

    • resp: Response

    Returns Promise<Response>

  • fetchConformanceStatement(baseUrl?: string, requestOptions?: RequestInit): Promise<CapabilityStatement>
  • Fetches the conformance statement from the given base URL. Note that the result is cached in memory (until the page is reloaded in the browser) because it might have to be re-used by the client

    Parameters

    • baseUrl: string = "/"

      The base URL of the FHIR server

    • Optional requestOptions: RequestInit

    Returns Promise<CapabilityStatement>

  • Given a token response, computes and returns the expiresAt timestamp. Note that this should only be used immediately after an access token is received, otherwise the computed timestamp will be incorrect.

    Parameters

    Returns number

  • getAndCache(url: string, requestOptions?: RequestInit, force?: boolean): Promise<any>
  • Makes a request using fetch and stores the result in internal memory cache. The cache is cleared when the page is unloaded.

    Parameters

    • url: string

      The URL to request

    • Optional requestOptions: RequestInit

      Request options

    • force: boolean = ...

      If true, reload from source and update the cache, even if it has already been cached.

    Returns Promise<any>

  • getPath(obj: Record<string, any>, path?: string): any
  • Walks through an object (or array) and returns the value found at the provided path. This function is very simple so it intentionally does not support any argument polymorphism, meaning that the path can only be a dot-separated string. If the path is invalid returns undefined.

    Parameters

    • obj: Record<string, any>

      The object (or Array) to walk through

    • path: string = ""

      The path (eg. "a.b.4.c")

    Returns any

    Whatever is found in the path or undefined

  • Given a conformance statement and a resource type, returns the name of the URL parameter that can be used to scope the resource type by patient ID.

    Parameters

    Returns string

  • getTargetWindow(target: WindowTarget, width?: number, height?: number): Promise<Window>
  • Resolves a reference to target window. It may also open new window or tab if the target = "popup" or target = "_blank".

    Parameters

    • target: WindowTarget
    • width: number = 800

      Only used when target = "popup"

    • height: number = 720

      Only used when target = "popup"

    Returns Promise<Window>

  • getTimeInFuture(secondsAhead?: number, from?: number | Date): number
  • Add a supplied number of seconds to the supplied Date, returning an integer number of seconds since the epoch

    Parameters

    • secondsAhead: number = 120

      How far ahead, in seconds (defaults to 120 seconds)

    • Optional from: number | Date

      Initial time (defaults to current time)

    Returns number

  • loweCaseKeys<T>(obj: T): T
  • Type parameters

    • T = undefined | any[] | Record<string, any>

    Parameters

    • obj: T

    Returns T

  • request<T>(url: string | Request, requestOptions?: FetchOptions): Promise<T>
  • This is our built-in request function. It does a few things by default (unless told otherwise):

    • Makes CORS requests
    • Sets accept header to "application/json"
    • Handles errors
    • If the response is json return the json object
    • If the response is text return the result text
    • Otherwise return the response object on which we call stuff like .blob()

    Type parameters

    Parameters

    Returns Promise<T>

  • responseToJSON(resp: Response): Promise<object | string>
  • Used in fetch Promise chains to return the JSON version of the response. Note that resp.json() will throw on empty body so we use resp.text() instead.

    Parameters

    • resp: Response

    Returns Promise<object | string>

  • setPath(obj: Record<string, any>, path: string, value: any, createEmpty?: boolean): Record<string, any>
  • Like getPath, but if the node is found, its value is set to @value

    Parameters

    • obj: Record<string, any>

      The object (or Array) to walk through

    • path: string

      The path (eg. "a.b.4.c")

    • value: any

      The value to set

    • createEmpty: boolean = false

      If true, create missing intermediate objects or arrays

    Returns Record<string, any>

    The modified object

Utility Functions

  • jwtDecode(token: string, env: Adapter): Record<string, any> | null
  • Decodes a JWT token and returns it's body.

    Parameters

    • token: string

      The token to read

    • env: Adapter

      An Adapter or any other object that has an atob method

    Returns Record<string, any> | null

  • makeArray<T>(arg: any): T[]
  • If the argument is an array returns it as is. Otherwise puts it in an array ([arg]) and returns the result

    Type parameters

    • T = any

    Parameters

    • arg: any

      The element to test and possibly convert to array

    Returns T[]

  • randomString(strLength?: number, charSet?: string): string
  • Generates random strings. By default this returns random 8 characters long alphanumeric strings.

    Parameters

    • strLength: number = 8

      The length of the output string. Defaults to 8.

    • charSet: string = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"

      A string containing all the possible characters. Defaults to all the upper and lower-case letters plus digits.

    Returns string

Generated using TypeDoc