export type ImageContent = {base64_content: string, original_filename: string}; export type CreateInsuranceCard = {image: ImageContent, rank: number, side: number}; export type CreateApiApi20PatientsIdInsuranceCardsArgs = {id: number, body: CreateInsuranceCard}; export type CreateApiApi20PatientsIdInsuranceCardsOptions = {baseUrl?: string | undefined, oauth2?: string | undefined, fetch?: typeof fetch | undefined}; /** * Create Patients Insurance Card * * POST /api/2.0/patients/{id}/insurance_cards/ */ export const createApiApi20PatientsIdInsuranceCards = async (args: CreateApiApi20PatientsIdInsuranceCardsArgs, options?: CreateApiApi20PatientsIdInsuranceCardsOptions) => { 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))}/insurance_cards/${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 };