export type RecordsEntry = {care_context_id?: string | undefined, checksum?: string | undefined, content?: string | undefined, media?: 'application/fhir+json' | undefined}; export type RecordsDHPubKey = {expiry?: string | undefined, key_value?: string | undefined, parameters?: string | undefined}; export type RecordsKeyMaterial = {crypto_alg?: string | undefined, curve?: string | undefined, dh_public_key?: RecordsDHPubKey | undefined, nonce?: string | undefined}; export type RecordsHipDataPushRequest = {entries?: Array | undefined, key_information?: RecordsKeyMaterial | undefined, page_count?: number | undefined, page_number?: number | undefined, transaction_id?: string | undefined}; export type CreateApiAbdmV1HipCareContextDataOnFetchArgs = {'X-Pt-Id'?: string | undefined, 'X-Partner-Pt-Id'?: string | undefined, 'X-Hip-Id'?: string | undefined, body: RecordsHipDataPushRequest}; export type CreateApiAbdmV1HipCareContextDataOnFetchOptions = {baseUrl?: string | undefined, authApiKey?: string | undefined, fetch?: typeof fetch | undefined}; /** * API for HIP to push care context FHIR data to HIU * * POST /abdm/v1/hip/care-context/data/on-fetch */ export const createApiAbdmV1HipCareContextDataOnFetch = async (args: CreateApiAbdmV1HipCareContextDataOnFetchArgs, options?: CreateApiAbdmV1HipCareContextDataOnFetchOptions) => { 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/hip/care-context/data/on-fetch${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 };