export type GetApiApi20ReportsIdPrintableArgs = {id: number, print_header?: number | undefined}; export type GetApiApi20ReportsIdPrintableOptions = {baseUrl?: string | undefined, oauth2?: string | undefined, fetch?: typeof fetch | undefined}; /** * Retrieve a printable view of a report * * GET /api/2.0/reports/{id}/printable/ */ export const getApiApi20ReportsIdPrintable = async (args: GetApiApi20ReportsIdPrintableArgs, options?: GetApiApi20ReportsIdPrintableOptions) => { const {baseUrl = "https://sandbox.elationemr.com/api/2.0", fetch: fetchFn = fetch, oauth2} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/pdf") if (args.print_header != null) query.append("print_header", String(args.print_header)) if (oauth2 !== undefined) headers.set('authorization', `Bearer ${oauth2}`) const url = `${baseUrl.replace(/\/+$/, '')}/api/2.0/reports/${encodeURIComponent(String(args.id))}/printable/${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return res.blob() };