export type GetApiPatientsPatientIdPatientPotassiumReportGraphArgs = {patient_id: number, date_since: string, date_until: string, disaggregated: boolean}; export type GetApiPatientsPatientIdPatientPotassiumReportGraphOptions = {baseUrl: string, bearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Get the patient's potassium graph * * GET /patients/{patient_id}/patient_potassium_report/graph */ export const getApiPatientsPatientIdPatientPotassiumReportGraph = async (args: GetApiPatientsPatientIdPatientPotassiumReportGraphArgs, options: GetApiPatientsPatientIdPatientPotassiumReportGraphOptions) => { const {baseUrl, fetch: fetchFn = fetch, bearerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "image/png") if (args.date_since != null) query.append("date_since", String(args.date_since)) if (args.date_until != null) query.append("date_until", String(args.date_until)) if (args.disaggregated != null) query.append("disaggregated", String(args.disaggregated)) if (bearerAuth !== undefined) headers.set('authorization', `Bearer ${bearerAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/patients/${encodeURIComponent(String(args.patient_id))}/patient_potassium_report/graph${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() };