export type CreateApiApi20PatientsIdIncomingFilesArgs = {id: number, body: {custom_title?: string | undefined, document_date?: string | undefined, document_tags?: Array | undefined, document_type: string, files: Array, import_history?: boolean | undefined, reviewer_user?: number | undefined, sign_off?: boolean | undefined, urgent?: boolean | undefined}}; export type CreateApiApi20PatientsIdIncomingFilesOptions = {baseUrl?: string | undefined, oauth2?: string | undefined, fetch?: typeof fetch | undefined}; /** * Create a new incoming file * * POST /api/2.0/patients/{id}/incoming_files/ */ export const createApiApi20PatientsIdIncomingFiles = async (args: CreateApiApi20PatientsIdIncomingFilesArgs, options?: CreateApiApi20PatientsIdIncomingFilesOptions) => { const {baseUrl = "https://sandbox.elationemr.com/api/2.0", fetch: fetchFn = fetch, oauth2} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (oauth2 !== undefined) headers.set('authorization', `Bearer ${oauth2}`) const url = `${baseUrl.replace(/\/+$/, '')}/api/2.0/patients/${encodeURIComponent(String(args.id))}/incoming_files/${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };