export type LinkCareContextMeta = {care_context_id?: string | undefined, data?: string | undefined, display?: string | undefined, hi_type?: ('OPConsultation' | 'Prescription' | 'DischargeSummary' | 'DiagnosticReport' | 'ImmunizationRecord' | 'HealthDocumentRecord' | 'WellnessRecord') | undefined, hi_types?: Array | undefined}; export type LinkCareContextLinkingRequest = {abha_address?: string | undefined, care_contexts?: Array | undefined, oid?: string | undefined, partner_user_id?: string | undefined}; export type CreateApiAbdmV1CareContextsLinkArgs = {'X-Pt-Id'?: string | undefined, 'X-Partner-Pt-Id'?: string | undefined, 'X-Hip-Id'?: string | undefined, body: LinkCareContextLinkingRequest}; export type CreateApiAbdmV1CareContextsLinkOptions = {baseUrl?: string | undefined, authApiKey?: string | undefined, fetch?: typeof fetch | undefined}; /** * Care context linking * * POST /abdm/v1/care-contexts/link */ export const createApiAbdmV1CareContextsLink = async (args: CreateApiAbdmV1CareContextsLinkArgs, options?: CreateApiAbdmV1CareContextsLinkOptions) => { const {baseUrl = "https://api.eka.care", fetch: fetchFn = fetch, authApiKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (args['X-Pt-Id'] != null) headers.set("X-Pt-Id", String(args['X-Pt-Id'])) if (args['X-Partner-Pt-Id'] != null) headers.set("X-Partner-Pt-Id", String(args['X-Partner-Pt-Id'])) if (args['X-Hip-Id'] != null) headers.set("X-Hip-Id", String(args['X-Hip-Id'])) if (authApiKey !== undefined) headers.set('authorization', `Bearer ${authApiKey}`) const url = `${baseUrl.replace(/\/+$/, '')}/abdm/v1/care-contexts/link${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 };