import {z} from 'zod' export type IdParam = string; export type UserParam = string; export type DeletedParam = number; export type CreatedByParam = string; export type UpdatedByParam = string; export type DeletedByParam = string; export type CreatedAtParam = string; export type UpdatedAtParam = string; export type DeletedAtParam = string; export type ExternalId = {source?: ('gcalendar' | 'successehs' | 'drchrono' | 'dentrix' | 'webpt' | 'theraoffice' | 'mi7' | 'practicefusion' | 'advancedmd' | 'acomrapidpm' | 'kareo' | 'nextech' | 'mwtherapy' | 'clinicient' | 'carecloud' | 'eclinicalmobile' | 'duxware' | 'labretriever' | 'optimispt' | 'referral' | 'recall' | 'allscriptspm' | 'lytec' | 'brightree' | 'fullslate' | 'nuemd' | 'centricityps' | 'officeally' | 'greenwayintergy' | 'compulink' | 'adspm' | 'dsnpm' | 'lumamock' | 'medicalmastermind' | 'meditouch' | 'healthnautica' | 'ezemrx' | 'hl7' | 'amazingcharts' | 'greenwayprimesuite' | 'raintree' | 'athenahealth' | 'revflow' | 'eclinicalworks10e' | 'hl7pickup' | 'mindbody' | 'eclinicalworkssql' | 'nextgen' | 'practiceperfect' | 'avimark' | 'clinix' | 'keymedical' | 'mdoffice' | 'webedoctor' | 'emapm' | 'medinformatix' | 'imsgo' | 'emds' | 'allscriptsunity' | 'medevolve' | 'caretracker' | 'clearpractice' | 'valant' | 'micromd' | 'systemedx' | 'medicalmaster' | 'athenamdp' | 'gmed' | 'roche' | 'onetouch' | 'somnoware' | 'managementplus' | 'lumacare' | 'nextechfhir' | 'curemd' | 'epic' | 'phoenixortho' | 'ezderm' | 'ggastromobile' | 'epicconfirmationpickup' | 'cerner' | 'allmeds' | 'oncoemrfilepickup' | 'imedicware' | 'modmedfhir' | 'clinux' | 'acuityscheduling' | 'medstreaming' | 'isalus' | 'meditechexpanse' | 'openemr' | 'genericfhir' | 'nextechpracticeplus' | 'sms' | 'voice' | 'email' | 'none') | undefined, value?: string | undefined}; export type SpecialtyRequestUpdate = {_id?: IdParam | undefined, user?: UserParam | undefined, deleted?: DeletedParam | undefined, createdBy?: CreatedByParam | undefined, updatedBy?: UpdatedByParam | undefined, deletedBy?: DeletedByParam | undefined, createdAt?: CreatedAtParam | undefined, updatedAt?: UpdatedAtParam | undefined, deletedAt?: DeletedAtParam | undefined, externalId?: ExternalId | undefined, name?: string | undefined, description?: string | undefined, phone?: string | undefined, directMessageAddress?: string | undefined, parentSpecialty?: string | undefined}; export type UpdateApiSpecialtiesSpecialtyIdArgs = {specialtyId: string, body: SpecialtyRequestUpdate}; export type UpdateApiSpecialtiesSpecialtyIdOptions = {baseUrl?: string | undefined, Bearer?: string | undefined, fetch?: typeof fetch | undefined}; export const idParam = z.string().min(24).max(24); export const userParam = z.string().min(24).max(24); export const deletedParam = z.union([z.literal(0), z.literal(1)]); export const createdByParam = z.string().min(24).max(24); export const updatedByParam = z.string().min(24).max(24); export const deletedByParam = z.string().min(24).max(24); export const createdAtParam = z.string(); export const updatedAtParam = z.string(); export const deletedAtParam = z.string(); export const externalId = z.object({source: z.enum(["gcalendar", "successehs", "drchrono", "dentrix", "webpt", "theraoffice", "mi7", "practicefusion", "advancedmd", "acomrapidpm", "kareo", "nextech", "mwtherapy", "clinicient", "carecloud", "eclinicalmobile", "duxware", "labretriever", "optimispt", "referral", "recall", "allscriptspm", "lytec", "brightree", "fullslate", "nuemd", "centricityps", "officeally", "greenwayintergy", "compulink", "adspm", "dsnpm", "lumamock", "medicalmastermind", "meditouch", "healthnautica", "ezemrx", "hl7", "amazingcharts", "greenwayprimesuite", "raintree", "athenahealth", "revflow", "eclinicalworks10e", "hl7pickup", "mindbody", "eclinicalworkssql", "nextgen", "practiceperfect", "avimark", "clinix", "keymedical", "mdoffice", "webedoctor", "emapm", "medinformatix", "imsgo", "emds", "allscriptsunity", "medevolve", "caretracker", "clearpractice", "valant", "micromd", "systemedx", "medicalmaster", "athenamdp", "gmed", "roche", "onetouch", "somnoware", "managementplus", "lumacare", "nextechfhir", "curemd", "epic", "phoenixortho", "ezderm", "ggastromobile", "epicconfirmationpickup", "cerner", "allmeds", "oncoemrfilepickup", "imedicware", "modmedfhir", "clinux", "acuityscheduling", "medstreaming", "isalus", "meditechexpanse", "openemr", "genericfhir", "nextechpracticeplus", "sms", "voice", "email", "none"]).optional(), value: z.string().optional()}); export const specialtyResponse = z.object({_id: idParam.optional(), user: userParam.optional(), deleted: deletedParam.optional(), createdBy: createdByParam.optional(), updatedBy: updatedByParam.optional(), deletedBy: deletedByParam.optional(), createdAt: createdAtParam.optional(), updatedAt: updatedAtParam.optional(), deletedAt: deletedAtParam.optional(), externalId: externalId.optional(), name: z.string().optional(), description: z.string().optional(), phone: z.string().optional(), directMessageAddress: z.string().optional(), parentSpecialty: z.string().min(24).max(24).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 a specialty * * PUT /specialties/{specialtyId} */ export const updateApiSpecialtiesSpecialtyId = async (args: UpdateApiSpecialtiesSpecialtyIdArgs, options?: UpdateApiSpecialtiesSpecialtyIdOptions) => { const {baseUrl = "https://api.lumahealth.io/api/v2", 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(/\/+$/, '')}/specialties/${encodeURIComponent(String(args.specialtyId))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PUT", 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(specialtyResponse, await res.json()) };