export type GetApiV1PatientsArgs = {gender?: string | undefined, marital_status?: string | undefined, phone?: string | undefined, ic?: string | undefined, uid?: string | undefined, total_visit?: number | undefined, total_visit__gte?: number | undefined, total_visit__lte?: number | undefined, panels?: string | undefined, services?: string | undefined, medications?: string | undefined, diagnoses?: string | undefined, search?: string | undefined, ordering?: string | undefined, limit?: number | undefined, offset?: number | undefined}; export type GetApiV1PatientsOptions = {baseUrl?: string | undefined, ApiKeyAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * List patients * * GET /v1/patients */ export const getApiV1Patients = async (args: GetApiV1PatientsArgs, options?: GetApiV1PatientsOptions) => { const {baseUrl = "https://developer.yezza.com", fetch: fetchFn = fetch, ApiKeyAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.gender != null) query.append("gender", String(args.gender)) if (args.marital_status != null) query.append("marital_status", String(args.marital_status)) if (args.phone != null) query.append("phone", String(args.phone)) if (args.ic != null) query.append("ic", String(args.ic)) if (args.uid != null) query.append("uid", String(args.uid)) if (args.total_visit != null) query.append("total_visit", String(args.total_visit)) if (args.total_visit__gte != null) query.append("total_visit__gte", String(args.total_visit__gte)) if (args.total_visit__lte != null) query.append("total_visit__lte", String(args.total_visit__lte)) if (args.panels != null) query.append("panels", String(args.panels)) if (args.services != null) query.append("services", String(args.services)) if (args.medications != null) query.append("medications", String(args.medications)) if (args.diagnoses != null) query.append("diagnoses", String(args.diagnoses)) if (args.search != null) query.append("search", String(args.search)) if (args.ordering != null) query.append("ordering", String(args.ordering)) if (args.limit != null) query.append("limit", String(args.limit)) if (args.offset != null) query.append("offset", String(args.offset)) 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: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };