import {z} from 'zod' export type GetApiPersonsPersonIdChartCareTeamMembersArgs = {$top: string, $filter: string, $orderby: string, $skip: string, $inlinecount: string, $count: string, personId: string, Accept: string}; export type GetApiPersonsPersonIdChartCareTeamMembersOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; export const link = z.object({href: z.string(), method: z.string(), rel: z.string(), description: z.string(), vendorExtensions: z.string()}); export const item6 = z.object({enterpriseId: z.string(), practiceId: z.string(), personId: z.string(), id: z.string(), providerId: z.string(), encounterId: z.string(), firstName: z.string(), lastName: z.string(), email: z.string(), activeDate: z.string(), inactiveDate: z.string(), address: z.string(), city: z.string(), state: z.string(), zip: z.string(), homePhone: z.string(), cellPhone: z.string(), fax: z.string(), agencyName: z.string(), agencyType: z.string(), patientRelationship: z.string(), supportRole: z.string(), specialty: z.string(), roleClass: z.string(), roleCode: z.string(), isReadOnly: z.string(), status: z.string(), _links: z.array(link)}); export const oK11 = z.object({Items: z.array(item6), NextPageLink: z.string(), Count: z.string()}); 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 }; /** * {{baseUrl}}/persons/:personId/chart/care-team-members * * GET /persons/{personId}/chart/care-team-members */ export const getApiPersonsPersonIdChartCareTeamMembers = async (args: GetApiPersonsPersonIdChartCareTeamMembersArgs, options?: GetApiPersonsPersonIdChartCareTeamMembersOptions) => { const {baseUrl = "https://nativeapi.nextgen.com/nge/prod/nge-api/api", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (args.$top != null) query.append("$top", String(args.$top)) if (args.$filter != null) query.append("$filter", String(args.$filter)) if (args.$orderby != null) query.append("$orderby", String(args.$orderby)) if (args.$skip != null) query.append("$skip", String(args.$skip)) if (args.$inlinecount != null) query.append("$inlinecount", String(args.$inlinecount)) if (args.$count != null) query.append("$count", String(args.$count)) if (args.Accept != null) headers.set("Accept", String(args.Accept)) const url = `${baseUrl.replace(/\/+$/, '')}/persons/${encodeURIComponent(String(args.personId))}/chart/care-team-members${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 validateResponse(oK11, await res.json()) };