export type GetApiInvoicesIdInsurancePacketPdfArgs = {id: string, patientId?: string | undefined}; export type GetApiInvoicesIdInsurancePacketPdfOptions = {baseUrl?: string | undefined, Bearer?: string | undefined, fetch?: typeof fetch | undefined}; /** * One pet's insurance packet (ITE-1177): its receipt for this bill plus the medical * record (SOAP, discharge, labs with report PDFs, vaccinations, radiology reports) of each * visit its charges came from, as one PDF. Reads are open under the permissions model * (docs/permissions.md), like the invoice and pet-receipt PDFs — but this one carries * medical records, so the caller must hold Patients, the permission the patient record * export itself requires. Checked here rather than as an attribute so the receipt-only * endpoints stay open to front-desk roles without it. * * GET /Invoices/{id}/insurance-packet-pdf */ export const getApiInvoicesIdInsurancePacketPdf = async (args: GetApiInvoicesIdInsurancePacketPdfArgs, options?: GetApiInvoicesIdInsurancePacketPdfOptions) => { const {baseUrl = "https://api.clinicos.vet/backend/business", fetch: fetchFn = fetch, Bearer} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/pdf") if (args.patientId != null) query.append("patientId", String(args.patientId)) if (Bearer !== undefined) headers.set('authorization', `Bearer ${Bearer}`) const url = `${baseUrl.replace(/\/+$/, '')}/Invoices/${encodeURIComponent(String(args.id))}/insurance-packet-pdf${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() };