export type CreateApiV1PatientsArgs = {body: {name: string, phone: string, ic?: string | undefined, email?: string | undefined, gender?: ('male' | 'female') | undefined, dob?: string | undefined, age?: number | undefined, nickname?: string | undefined, nationality?: string | undefined, race?: string | undefined, religion?: string | undefined, occupation?: string | undefined, marital_status?: ('married' | 'single') | undefined, staff_id?: string | undefined, address?: ({address_1: string, address_2?: string | undefined, postcode: string, city: string, state: string, country?: string | undefined}) | undefined, emergency_contact?: ({name?: string | undefined, relationship?: string | undefined, phone?: string | undefined}) | undefined, panels?: (Array<{panel?: number | undefined, staff_id?: string | undefined, note?: string | undefined}>) | undefined, tagging?: Array | undefined}}; export type CreateApiV1PatientsOptions = {baseUrl?: string | undefined, ApiKeyAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Create a patient * * POST /v1/patients */ export const createApiV1Patients = async (args: CreateApiV1PatientsArgs, options?: CreateApiV1PatientsOptions) => { const {baseUrl = "https://developer.yezza.com", fetch: fetchFn = fetch, ApiKeyAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (ApiKeyAuth !== undefined) headers.set("X-Api-Key", ApiKeyAuth) const url = `${baseUrl.replace(/\/+$/, '')}/v1/patients${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 };