import {z} from 'zod' export type PatchApiDrV1PatientPatientIdArgs = {auth: string, patient_id: string, partner_id: string, body: {designation?: ('Mr.' | 'Ms.' | 'Mrs.' | 'Miss.' | 'Kumar.' | 'Shri.' | 'Smt.' | 'Dr.' | 'Master.' | 'Baby.' | 'Mohd.' | 'B/O') | undefined, first_name?: string | undefined, middle_name?: string | undefined, last_name?: string | undefined, gender?: ('M' | 'F' | 'O') | undefined, address?: ({city?: string | undefined, line1?: string | undefined, line2?: string | undefined, pincode?: number | undefined, state?: string | undefined, country?: string | undefined}) | undefined, partner_meta?: ({key1?: string | undefined}) | undefined, dob?: string | undefined} | {designation?: ('Mr.' | 'Ms.' | 'Mrs.' | 'Miss.' | 'Kumar.' | 'Shri.' | 'Smt.' | 'Dr.' | 'Master.' | 'Baby.' | 'Mohd.' | 'B/O') | undefined, first_name?: string | undefined, middle_name?: string | undefined, last_name?: string | undefined, gender?: ('M' | 'F' | 'O') | undefined, address?: ({city?: string | undefined, line1?: string | undefined, line2?: string | undefined, pincode?: number | undefined, state?: string | undefined, country?: string | undefined}) | undefined, partner_meta?: ({key1?: string | undefined}) | undefined, age?: number | undefined}}; export type PatchApiDrV1PatientPatientIdOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; export const patchApiDrV1PatientPatientIdResponse = z.object({patient_id: z.string().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 }; /** * Update Patient Details * * PATCH /dr/v1/patient/{patient_id} */ export const patchApiDrV1PatientPatientId = async (args: PatchApiDrV1PatientPatientIdArgs, options?: PatchApiDrV1PatientPatientIdOptions) => { const {baseUrl = "https://api.eka.care", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (args.auth != null) headers.set("auth", String(args.auth)) if (args.partner_id != null) query.append("partner_id", String(args.partner_id)) const url = `${baseUrl.replace(/\/+$/, '')}/dr/v1/patient/${encodeURIComponent(String(args.patient_id))}${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(patchApiDrV1PatientPatientIdResponse, await res.json()) };