export type CreateApiToolsDicomEchoArgs = {body: {AET?: string | undefined, CheckFind?: boolean | undefined, Host?: string | undefined, LocalAet?: string | undefined, Manufacturer?: string | undefined, Port?: number | undefined, Timeout?: number | undefined, UseDicomTls?: boolean | undefined}}; export type CreateApiToolsDicomEchoOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Trigger C-ECHO SCU * * POST /tools/dicom-echo */ export const createApiToolsDicomEcho = async (args: CreateApiToolsDicomEchoArgs, options?: CreateApiToolsDicomEchoOptions) => { const {baseUrl = "https://orthanc.uclouvain.be/demo", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") const url = `${baseUrl.replace(/\/+$/, '')}/tools/dicom-echo${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 };