import {z} from 'zod' export type DiagnosticsSettingsDto = {courierCutoffTime?: (string | null) | undefined, autoAttachLabResults?: boolean | undefined, dicomAeTitle?: (string | null) | undefined, dicomIp?: (string | null) | undefined, dicomPort?: (number | unknown | null) | undefined, imagingRetentionPolicy?: string | undefined, autoRouteImages?: boolean | undefined, teleradiologyVetRad?: boolean | undefined, teleradiologyStatRad?: boolean | undefined, autoSubmitStudies?: boolean | undefined, autoSyncWithRecords?: boolean | undefined, calibrationAlertsEnabled?: boolean | undefined, scoutDistressDetection?: boolean | undefined, scoutPulseCheck?: boolean | undefined, tempMonitoringEnabled?: boolean | undefined, fridgeFreezerSensors?: boolean | undefined, pawsTvEnabled?: boolean | undefined, pawsTvDefaultChannel?: (string | null) | undefined, criticalLabResultAlerts?: boolean | undefined, statCaseResultAlerts?: boolean | undefined, equipmentCalibrationAlerts?: boolean | undefined}; export type PatchApiClinicConfigDiagnosticsArgs = {body: DiagnosticsSettingsDto}; export type PatchApiClinicConfigDiagnosticsOptions = {baseUrl?: string | undefined, Bearer?: string | undefined, fetch?: typeof fetch | undefined}; export const diagnosticsSettingsDto = z.object({courierCutoffTime: z.string().nullable().optional(), autoAttachLabResults: z.boolean().optional(), dicomAeTitle: z.string().nullable().optional(), dicomIp: z.string().nullable().optional(), dicomPort: z.union([z.number().int(), z.string()]).nullable().optional(), imagingRetentionPolicy: z.string().optional(), autoRouteImages: z.boolean().optional(), teleradiologyVetRad: z.boolean().optional(), teleradiologyStatRad: z.boolean().optional(), autoSubmitStudies: z.boolean().optional(), autoSyncWithRecords: z.boolean().optional(), calibrationAlertsEnabled: z.boolean().optional(), scoutDistressDetection: z.boolean().optional(), scoutPulseCheck: z.boolean().optional(), tempMonitoringEnabled: z.boolean().optional(), fridgeFreezerSensors: z.boolean().optional(), pawsTvEnabled: z.boolean().optional(), pawsTvDefaultChannel: z.string().nullable().optional(), criticalLabResultAlerts: z.boolean().optional(), statCaseResultAlerts: z.boolean().optional(), equipmentCalibrationAlerts: z.boolean().optional()}); export const validateResponse = async ( schema: { readonly '~standard': { readonly validate: (value: unknown) => ({ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }) | Promise<{ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }> } }, value: unknown ): Promise => { const result = await schema['~standard'].validate(value) if (result.issues !== undefined) { const detail = result.issues .map(({ message, path }) => path?.length ? `${path.map((segment) => String(typeof segment === 'object' ? segment.key : segment)).join('.')}: ${message}` : message ) .join('; ') throw new Error(`Response does not match the schema: ${detail}`, { cause: { issues: result.issues } }) } return result.value }; /** * PATCH /clinic-config/diagnostics - Update diagnostics settings * * PATCH /clinic-config/diagnostics */ export const patchApiClinicConfigDiagnostics = async (args: PatchApiClinicConfigDiagnosticsArgs, options?: PatchApiClinicConfigDiagnosticsOptions) => { const {baseUrl = "https://api.clinicos.vet/backend/business", fetch: fetchFn = fetch, Bearer} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (Bearer !== undefined) headers.set('authorization', `Bearer ${Bearer}`) const url = `${baseUrl.replace(/\/+$/, '')}/clinic-config/diagnostics${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PATCH", 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 validateResponse(diagnosticsSettingsDto, await res.json()) };