@oystehr/sdk 4.3.8 → 4.3.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  import { Address as AddressR4B, HumanName as HumanNameR4B } from 'fhir/r4b';
2
2
  import { Address as AddressR5, HumanName as HumanNameR5 } from 'fhir/r5';
3
- import { BatchBundle, BatchInput, Bundle, FhirCreateParams, FhirDeleteParams, FhirGetParams, FhirHistoryGetParams, FhirHistorySearchParams, FhirPatchParams, FhirResource, FhirResourceReturnValue, FhirSearchParams, FhirUpdateParams, GenerateFriendlyPatientIdParams, TransactionBundle } from '../..';
3
+ import { BatchBundle, BatchInput, Bundle, FhirAsyncJobHandle, FhirAsyncJobStatus, FhirAsyncWaitOptions, FhirCreateParams, FhirDeleteParams, FhirGetParams, FhirHistoryGetParams, FhirHistorySearchParams, FhirPatchParams, FhirResource, FhirResourceReturnValue, FhirResponseMode, FhirSearchParams, FhirUpdateParams, GenerateFriendlyPatientIdParams, TransactionBundle } from '../..';
4
4
  import { FhirFetcherResponse, OystehrClientRequest, SDKResource } from '../../client/client';
5
5
  /**
6
6
  * Optional parameter that can be passed to the client methods. It allows
@@ -23,18 +23,73 @@ export interface OystehrFHIRUpdateClientRequest extends OystehrClientRequest {
23
23
  * @param request optional OystehrClientRequest object
24
24
  * @returns FHIR Bundle resource
25
25
  */
26
- export declare function search<T extends FhirResource>(this: SDKResource, params: FhirSearchParams<T>, request?: OystehrClientRequest): Promise<FhirFetcherResponse<Bundle<T>>>;
27
- export declare function create<T extends FhirResource>(this: SDKResource, params: FhirCreateParams<T>, request?: OystehrClientRequest): Promise<FhirFetcherResponse<FhirResourceReturnValue<T>>>;
28
- export declare function get<T extends FhirResource>(this: SDKResource, { resourceType, id }: FhirGetParams<T>, request?: OystehrClientRequest): Promise<FhirFetcherResponse<FhirResourceReturnValue<T>>>;
29
- export declare function update<T extends FhirResource>(this: SDKResource, params: FhirUpdateParams<T>, request?: OystehrFHIRUpdateClientRequest): Promise<FhirFetcherResponse<FhirResourceReturnValue<T>>>;
30
- export declare function patch<T extends FhirResource>(this: SDKResource, { resourceType, id, operations }: FhirPatchParams<T>, request?: OystehrFHIRUpdateClientRequest): Promise<FhirFetcherResponse<FhirResourceReturnValue<T>>>;
31
- declare function del<T extends FhirResource>(this: SDKResource, { resourceType, id }: FhirDeleteParams<T>, request?: OystehrClientRequest): Promise<FhirFetcherResponse<FhirResourceReturnValue<T>>>;
26
+ export declare function search<T extends FhirResource>(this: SDKResource, params: FhirSearchParams<T>, request: OystehrClientRequest & {
27
+ mode: Exclude<FhirResponseMode, 'sync'>;
28
+ }): Promise<FhirAsyncJobHandle>;
29
+ export declare function search<T extends FhirResource>(this: SDKResource, params: FhirSearchParams<T>, request?: OystehrClientRequest & {
30
+ mode?: 'sync' | undefined;
31
+ }): Promise<FhirFetcherResponse<Bundle<T>>>;
32
+ export declare function create<T extends FhirResource>(this: SDKResource, params: FhirCreateParams<T>, request: OystehrClientRequest & {
33
+ mode: Exclude<FhirResponseMode, 'sync'>;
34
+ }): Promise<FhirAsyncJobHandle>;
35
+ export declare function create<T extends FhirResource>(this: SDKResource, params: FhirCreateParams<T>, request?: OystehrClientRequest & {
36
+ mode?: 'sync' | undefined;
37
+ }): Promise<FhirFetcherResponse<FhirResourceReturnValue<T>>>;
38
+ export declare function get<T extends FhirResource>(this: SDKResource, { resourceType, id }: FhirGetParams<T>, request: OystehrClientRequest & {
39
+ mode: Exclude<FhirResponseMode, 'sync'>;
40
+ }): Promise<FhirAsyncJobHandle>;
41
+ export declare function get<T extends FhirResource>(this: SDKResource, { resourceType, id }: FhirGetParams<T>, request?: OystehrClientRequest & {
42
+ mode?: 'sync' | undefined;
43
+ }): Promise<FhirFetcherResponse<FhirResourceReturnValue<T>>>;
44
+ export declare function update<T extends FhirResource>(this: SDKResource, params: FhirUpdateParams<T>, request: OystehrFHIRUpdateClientRequest & {
45
+ mode: Exclude<FhirResponseMode, 'sync'>;
46
+ }): Promise<FhirAsyncJobHandle>;
47
+ export declare function update<T extends FhirResource>(this: SDKResource, params: FhirUpdateParams<T>, request?: OystehrFHIRUpdateClientRequest & {
48
+ mode?: 'sync' | undefined;
49
+ }): Promise<FhirFetcherResponse<FhirResourceReturnValue<T>>>;
50
+ export declare function patch<T extends FhirResource>(this: SDKResource, params: FhirPatchParams<T>, request: OystehrFHIRUpdateClientRequest & {
51
+ mode: Exclude<FhirResponseMode, 'sync'>;
52
+ }): Promise<FhirAsyncJobHandle>;
53
+ export declare function patch<T extends FhirResource>(this: SDKResource, params: FhirPatchParams<T>, request?: OystehrFHIRUpdateClientRequest & {
54
+ mode?: 'sync' | undefined;
55
+ }): Promise<FhirFetcherResponse<FhirResourceReturnValue<T>>>;
56
+ declare function del<T extends FhirResource>(this: SDKResource, params: FhirDeleteParams<T>, request: OystehrClientRequest & {
57
+ mode: Exclude<FhirResponseMode, 'sync'>;
58
+ }): Promise<FhirAsyncJobHandle>;
59
+ declare function del<T extends FhirResource>(this: SDKResource, params: FhirDeleteParams<T>, request?: OystehrClientRequest & {
60
+ mode?: 'sync' | undefined;
61
+ }): Promise<FhirFetcherResponse<FhirResourceReturnValue<T>>>;
32
62
  export { del as delete };
33
- export declare function history<T extends FhirResource>(this: SDKResource, { resourceType, id }: FhirHistorySearchParams<T>, request?: OystehrClientRequest): Promise<FhirFetcherResponse<Bundle<T>>>;
34
- export declare function history<T extends FhirResource>(this: SDKResource, { resourceType, id, versionId }: FhirHistoryGetParams<T>, request?: OystehrClientRequest): Promise<FhirFetcherResponse<T>>;
35
- export declare function history<T extends FhirResource>(this: SDKResource, { resourceType, id, count, offset }: FhirHistorySearchParams<T>, request?: OystehrClientRequest): Promise<FhirFetcherResponse<Bundle<T>>>;
36
- export declare function batch<BundleContentType extends FhirResource>(this: SDKResource, input: BatchInput<BundleContentType>, request?: OystehrClientRequest): Promise<FhirFetcherResponse<BatchBundle<BundleContentType>>>;
37
- export declare function transaction<BundleContentType extends FhirResource>(this: SDKResource, input: BatchInput<BundleContentType>, request?: OystehrClientRequest): Promise<FhirFetcherResponse<TransactionBundle<BundleContentType>>>;
63
+ export declare function getAsyncJob<T extends FhirResource>(this: SDKResource, jobId: string, request?: OystehrClientRequest): Promise<FhirAsyncJobStatus<T>>;
64
+ export declare function waitForAsyncJob<T extends FhirResource>(this: SDKResource, jobId: string, options?: FhirAsyncWaitOptions, request?: OystehrClientRequest): Promise<FhirAsyncJobStatus<T>>;
65
+ export declare function cancelAsyncJob(this: SDKResource, jobId: string, request?: OystehrClientRequest): Promise<void>;
66
+ export declare function history<T extends FhirResource>(this: SDKResource, { resourceType, id }: FhirHistorySearchParams<T>, request: OystehrClientRequest & {
67
+ mode: Exclude<FhirResponseMode, 'sync'>;
68
+ }): Promise<FhirAsyncJobHandle>;
69
+ export declare function history<T extends FhirResource>(this: SDKResource, { resourceType, id, versionId }: FhirHistoryGetParams<T>, request: OystehrClientRequest & {
70
+ mode: Exclude<FhirResponseMode, 'sync'>;
71
+ }): Promise<FhirAsyncJobHandle>;
72
+ export declare function history<T extends FhirResource>(this: SDKResource, { resourceType, id, versionId }: FhirHistoryGetParams<T>, request?: OystehrClientRequest & {
73
+ mode?: 'sync' | undefined;
74
+ }): Promise<FhirFetcherResponse<T>>;
75
+ export declare function history<T extends FhirResource>(this: SDKResource, { resourceType, id }: FhirHistorySearchParams<T>, request?: OystehrClientRequest & {
76
+ mode?: 'sync' | undefined;
77
+ }): Promise<FhirFetcherResponse<Bundle<T>>>;
78
+ export declare function history<T extends FhirResource>(this: SDKResource, { resourceType, id, count, offset }: FhirHistorySearchParams<T>, request?: OystehrClientRequest & {
79
+ mode?: 'sync' | undefined;
80
+ }): Promise<FhirFetcherResponse<Bundle<T>>>;
81
+ export declare function batch<BundleContentType extends FhirResource>(this: SDKResource, input: BatchInput<BundleContentType>, request: OystehrClientRequest & {
82
+ mode: Exclude<FhirResponseMode, 'sync'>;
83
+ }): Promise<FhirAsyncJobHandle>;
84
+ export declare function batch<BundleContentType extends FhirResource>(this: SDKResource, input: BatchInput<BundleContentType>, request?: OystehrClientRequest & {
85
+ mode?: 'sync' | undefined;
86
+ }): Promise<FhirFetcherResponse<BatchBundle<BundleContentType>>>;
87
+ export declare function transaction<BundleContentType extends FhirResource>(this: SDKResource, input: BatchInput<BundleContentType>, request: OystehrClientRequest & {
88
+ mode: Exclude<FhirResponseMode, 'sync'>;
89
+ }): Promise<FhirAsyncJobHandle>;
90
+ export declare function transaction<BundleContentType extends FhirResource>(this: SDKResource, input: BatchInput<BundleContentType>, request?: OystehrClientRequest & {
91
+ mode?: 'sync' | undefined;
92
+ }): Promise<FhirFetcherResponse<TransactionBundle<BundleContentType>>>;
38
93
  export declare function generateFriendlyPatientId(this: SDKResource, { id }: GenerateFriendlyPatientIdParams, request?: OystehrClientRequest): Promise<FhirFetcherResponse<FhirResource>>;
39
94
  export declare function formatAddress(address: AddressR4B | AddressR5, options?: {
40
95
  all?: boolean;
@@ -1,5 +1,5 @@
1
1
  import { addParamsToSearch } from '../../client/client.js';
2
- import { OystehrFHIRError, OystehrSdkError } from '../../errors/index.js';
2
+ import { OystehrSdkError, OystehrFHIRError } from '../../errors/index.js';
3
3
 
4
4
  // Code adapted from https://github.com/sindresorhus/uint8array-extras
5
5
  const MAX_BLOCK_SIZE = 65_535;
@@ -193,13 +193,9 @@ function assertRetrievedResource(config, resource) {
193
193
  }
194
194
  }
195
195
  }
196
- /**
197
- * Performs a FHIR search and returns the results as a Bundle resource
198
- *
199
- * @param options FHIR resource type and FHIR search parameters
200
- * @param request optional OystehrClientRequest object
201
- * @returns FHIR Bundle resource
202
- */
196
+ function isAsyncRequestMode(mode) {
197
+ return mode === 'async-bundle' || mode === 'async-bulk';
198
+ }
203
199
  async function search(params, request) {
204
200
  const { resourceType } = params;
205
201
  const taggedParams = applyTagSearchParams(this.config, params.params);
@@ -213,6 +209,13 @@ async function search(params, request) {
213
209
  return acc;
214
210
  }, {});
215
211
  }
212
+ const requestMode = request?.mode;
213
+ if (isAsyncRequestMode(requestMode)) {
214
+ return await this.startAsyncJob(`/${resourceType}/_search`, 'POST', paramMap ?? {}, requestMode, {
215
+ ...request,
216
+ contentType: 'application/x-www-form-urlencoded',
217
+ });
218
+ }
216
219
  const requestBundle = await this.fhirRequest(`/${resourceType}/_search`, 'POST')(paramMap, {
217
220
  ...request,
218
221
  contentType: 'application/x-www-form-urlencoded',
@@ -229,9 +232,17 @@ async function search(params, request) {
229
232
  async function create(params, request) {
230
233
  const tagged = applyTagToResource(this.config, params);
231
234
  const { resourceType } = tagged;
232
- return this.fhirRequest(`/${resourceType}`, 'POST')(tagged, request);
235
+ const requestMode = request?.mode;
236
+ if (isAsyncRequestMode(requestMode)) {
237
+ return await this.startAsyncJob(`/${resourceType}`, 'POST', tagged, requestMode, request);
238
+ }
239
+ return await this.fhirRequest(`/${resourceType}`, 'POST')(tagged, request);
233
240
  }
234
241
  async function get({ resourceType, id }, request) {
242
+ const requestMode = request?.mode;
243
+ if (isAsyncRequestMode(requestMode)) {
244
+ return await this.startAsyncJob(`/${resourceType}/${id}`, 'GET', {}, requestMode, request);
245
+ }
235
246
  const result = await this.fhirRequest(`/${resourceType}/${id}`, 'GET')({}, request);
236
247
  assertRetrievedResource(this.config, result);
237
248
  return result;
@@ -239,23 +250,90 @@ async function get({ resourceType, id }, request) {
239
250
  async function update(params, request) {
240
251
  const tagged = applyTagToResource(this.config, params);
241
252
  const { id, resourceType } = tagged;
242
- return this.fhirRequest(`/${resourceType}/${id}`, 'PUT')(tagged, {
253
+ const requestMode = request?.mode;
254
+ const ifMatchRequest = {
243
255
  ...request,
244
256
  ifMatch: request?.optimisticLockingVersionId ? `W/"${request.optimisticLockingVersionId}"` : undefined,
245
- });
257
+ };
258
+ if (isAsyncRequestMode(requestMode)) {
259
+ return await this.startAsyncJob(`/${resourceType}/${id}`, 'PUT', tagged, requestMode, ifMatchRequest);
260
+ }
261
+ return await this.fhirRequest(`/${resourceType}/${id}`, 'PUT')(tagged, ifMatchRequest);
246
262
  }
247
263
  async function patch({ resourceType, id, operations }, request) {
248
264
  const taggedOperations = applyTagToPatchOperations(this.config, operations);
249
- return this.fhirRequest(`/${resourceType}/${id}`, 'PATCH')(taggedOperations, {
265
+ const requestMode = request?.mode;
266
+ const ifMatchRequest = {
250
267
  ...request,
251
- contentType: 'application/json-patch+json',
252
268
  ifMatch: request?.optimisticLockingVersionId ? `W/"${request.optimisticLockingVersionId}"` : undefined,
269
+ };
270
+ if (isAsyncRequestMode(requestMode)) {
271
+ return await this.startAsyncJob(`/${resourceType}/${id}`, 'PATCH', taggedOperations, requestMode, {
272
+ ...ifMatchRequest,
273
+ contentType: 'application/json-patch+json',
274
+ });
275
+ }
276
+ return this.fhirRequest(`/${resourceType}/${id}`, 'PATCH')(taggedOperations, {
277
+ ...ifMatchRequest,
278
+ contentType: 'application/json-patch+json',
253
279
  });
254
280
  }
255
281
  async function del({ resourceType, id }, request) {
256
- return this.fhirRequest(`/${resourceType}/${id}`, 'DELETE')({}, request);
282
+ const requestMode = request?.mode;
283
+ if (isAsyncRequestMode(requestMode)) {
284
+ return await this.startAsyncJob(`/${resourceType}/${id}`, 'DELETE', {}, requestMode, request);
285
+ }
286
+ return await this.fhirRequest(`/${resourceType}/${id}`, 'DELETE')({}, request);
287
+ }
288
+ function getRetryDelayMs(retryAfter, fallbackMs) {
289
+ if (!retryAfter) {
290
+ return fallbackMs;
291
+ }
292
+ const asSeconds = Number(retryAfter);
293
+ if (Number.isFinite(asSeconds) && asSeconds >= 0) {
294
+ return Math.max(0, Math.floor(asSeconds * 1000));
295
+ }
296
+ const asTimestamp = Date.parse(retryAfter);
297
+ if (Number.isFinite(asTimestamp)) {
298
+ return Math.max(0, asTimestamp - Date.now());
299
+ }
300
+ return fallbackMs;
301
+ }
302
+ async function getAsyncJob(jobId, request) {
303
+ return await this.fetchAsyncJobStatus(jobId, request);
304
+ }
305
+ async function waitForAsyncJob(jobId, options, request) {
306
+ // 5 seconds poll interval by default
307
+ const pollIntervalMs = options?.pollIntervalMs ?? 5000;
308
+ // 15 minutes timout by default
309
+ const timeoutMs = options?.timeoutMs ?? 900000;
310
+ const attempts = Math.max(1, Math.ceil(timeoutMs / pollIntervalMs));
311
+ for (let attempt = 0; attempt < attempts; attempt++) {
312
+ const status = await this.fetchAsyncJobStatus(jobId, request);
313
+ if (status.status !== 202) {
314
+ return status;
315
+ }
316
+ if (attempt < attempts - 1) {
317
+ const retryAfter = 'retryAfter' in status ? status.retryAfter : undefined;
318
+ await new Promise((resolve) => setTimeout(resolve, getRetryDelayMs(retryAfter, pollIntervalMs)));
319
+ }
320
+ }
321
+ throw new OystehrSdkError({
322
+ message: `Async job ${jobId} did not complete within ${timeoutMs} ms`,
323
+ code: 408,
324
+ });
325
+ }
326
+ async function cancelAsyncJob(jobId, request) {
327
+ await this.fhirRequest(`/async-job/${jobId}`, 'DELETE')({}, request);
257
328
  }
258
329
  async function history({ resourceType, id, versionId, count, offset, }, request) {
330
+ const requestMode = request?.mode;
331
+ if (isAsyncRequestMode(requestMode)) {
332
+ if (versionId) {
333
+ return await this.startAsyncJob(`/${resourceType}/${id}/_history/${versionId}`, 'GET', {}, requestMode, request);
334
+ }
335
+ return await this.startAsyncJob(`/${resourceType}/${id}/_history`, 'GET', {}, requestMode, request);
336
+ }
259
337
  if (versionId) {
260
338
  return this.fhirRequest(`/${resourceType}/${id}/_history/${versionId}`, 'GET')({}, request);
261
339
  }
@@ -399,11 +477,16 @@ function batchInputRequestToBundleEntryItem(request, config) {
399
477
  throw new Error('Unrecognized method');
400
478
  }
401
479
  async function batch(input, request) {
402
- const resp = await this.fhirRequest('/', 'POST')({
480
+ const requestPayload = {
403
481
  resourceType: 'Bundle',
404
482
  type: 'batch',
405
483
  entry: input.requests.map((req) => batchInputRequestToBundleEntryItem(req, this.config)),
406
- }, request);
484
+ };
485
+ const requestMode = request?.mode;
486
+ if (isAsyncRequestMode(requestMode)) {
487
+ return await this.startAsyncJob('/', 'POST', requestPayload, requestMode, request);
488
+ }
489
+ const resp = await this.fhirRequest('/', 'POST')(requestPayload, request);
407
490
  // Validate each GET/HEAD retrieval entry against the tag config.
408
491
  // Violations are replaced with a synthetic 404 OperationOutcome entry; batch entries are independent.
409
492
  const rawEntries = resp.entry;
@@ -446,11 +529,16 @@ async function batch(input, request) {
446
529
  return bundle;
447
530
  }
448
531
  async function transaction(input, request) {
449
- const resp = await this.fhirRequest('/', 'POST')({
532
+ const requestPayload = {
450
533
  resourceType: 'Bundle',
451
534
  type: 'transaction',
452
535
  entry: input.requests.map((req) => batchInputRequestToBundleEntryItem(req, this.config)),
453
- }, request);
536
+ };
537
+ const requestMode = request?.mode;
538
+ if (isAsyncRequestMode(requestMode)) {
539
+ return await this.startAsyncJob('/', 'POST', requestPayload, requestMode, request);
540
+ }
541
+ const resp = await this.fhirRequest('/', 'POST')(requestPayload, request);
454
542
  // Validate each GET/HEAD retrieval entry against the tag config.
455
543
  // A violation throws OystehrFHIRError(404) — transactions are all-or-nothing.
456
544
  if (this.config.workspaceTag || this.config.ignoreTags?.length) {
@@ -520,5 +608,5 @@ function formatHumanName(name, options) {
520
608
  return builder.join(' ').trim();
521
609
  }
522
610
 
523
- export { batch, create, del as delete, formatAddress, formatHumanName, generateFriendlyPatientId, get, history, patch, search, transaction, update };
611
+ export { batch, cancelAsyncJob, create, del as delete, formatAddress, formatHumanName, generateFriendlyPatientId, get, getAsyncJob, history, patch, search, transaction, update, waitForAsyncJob };
524
612
  //# sourceMappingURL=fhir-ext.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"fhir-ext.js","sources":["../../../../src/resources/classes/fhir-ext.ts"],"sourcesContent":["import type { Operation } from 'fast-json-patch';\nimport { Address as AddressR4B, HumanName as HumanNameR4B } from 'fhir/r4b';\nimport { Address as AddressR5, HumanName as HumanNameR5 } from 'fhir/r5';\nimport {\n BatchBundle,\n BatchInput,\n BatchInputRequest,\n Binary,\n Bundle,\n BundleEntry,\n Coding,\n FhirBundle,\n FhirCreateParams,\n FhirDeleteParams,\n FhirGetParams,\n FhirHistoryGetParams,\n FhirHistorySearchParams,\n FhirPatchParams,\n FhirResource,\n FhirResourceReturnValue,\n FhirSearchParams,\n FhirUpdateParams,\n GenerateFriendlyPatientIdParams,\n OperationOutcome,\n Resource,\n SearchParam,\n TransactionBundle,\n} from '../..';\nimport { addParamsToSearch, FhirFetcherResponse, OystehrClientRequest, SDKResource } from '../../client/client';\nimport { OystehrConfig } from '../../config';\nimport { OystehrFHIRError, OystehrSdkError } from '../../errors';\n\n// Code adapted from https://github.com/sindresorhus/uint8array-extras\nconst MAX_BLOCK_SIZE = 65_535;\nfunction stringToBase64(input: string): string {\n const data: Uint8Array<ArrayBuffer> = new globalThis.TextEncoder().encode(input);\n let base64 = '';\n\n for (let index = 0; index < data.length; index += MAX_BLOCK_SIZE) {\n const chunk = data.subarray(index, index + MAX_BLOCK_SIZE);\n // Required as `btoa` and `atob` don't properly support Unicode: https://developer.mozilla.org/en-US/docs/Glossary/Base64#the_unicode_problem\n base64 += globalThis.btoa(String.fromCodePoint.apply(undefined, chunk as unknown as number[]));\n }\n return base64;\n}\n\nfunction base64ToString(input: string): string {\n const binaryString = globalThis.atob(input);\n const bytes = new Uint8Array(binaryString.length);\n for (let i = 0; i < binaryString.length; i++) {\n bytes[i] = binaryString.charCodeAt(i);\n }\n return new globalThis.TextDecoder().decode(bytes);\n}\n\n// ─── Tag-mode helpers ────────────────────────────────────────────────────────\n\n/** Converts a Coding to the FHIR _tag parameter value format \"system|code\". */\nfunction codingToTagValue(coding: Coding): string {\n return coding.system ? `${coding.system}|${coding.code ?? ''}` : coding.code ?? '';\n}\n\n/** Returns true if two Codings match on system (treating absent as empty string) and code. */\nfunction codingMatches(a: Coding, b: Coding): boolean {\n return (a.system ?? '') === (b.system ?? '') && (a.code ?? '') === (b.code ?? '');\n}\n\n/**\n * Appends _tag (tag-workspace mode) or _tag:not (ignore-tags mode) search\n * params to an existing SearchParam array and returns the new array.\n */\nfunction applyTagSearchParams(config: OystehrConfig, params: SearchParam[] | undefined): SearchParam[] {\n const out: SearchParam[] = params ? [...params] : [];\n if (config.workspaceTag) {\n out.push({ name: '_tag', value: codingToTagValue(config.workspaceTag) });\n } else if (config.ignoreTags?.length) {\n for (const tag of config.ignoreTags) {\n out.push({ name: '_tag:not', value: codingToTagValue(tag) });\n }\n }\n return out;\n}\n\n/**\n * In ignore-tags mode: throws OystehrSdkError if the resource carries any ignored tag.\n * In tag-workspace mode: injects the workspace tag into resource.meta.tag if not already present.\n * Returns the (possibly cloned) resource.\n */\nfunction applyTagToResource<T extends FhirResource>(config: OystehrConfig, resource: T): T {\n const resourceLike = resource as unknown as Resource;\n\n if (config.ignoreTags?.length) {\n const resourceTags = (resourceLike.meta?.tag ?? []) as Coding[];\n for (const ignored of config.ignoreTags) {\n if (resourceTags.some((t) => codingMatches(t, ignored))) {\n throw new OystehrSdkError({\n message: `Resource has an ignored tag (system: \"${ignored.system ?? ''}\", code: \"${\n ignored.code ?? ''\n }\") and cannot be mutated in ignoreTags mode`,\n code: 400,\n });\n }\n }\n return resource;\n }\n\n if (config.workspaceTag) {\n const tag = config.workspaceTag;\n const existingTags = (resourceLike.meta?.tag ?? []) as Coding[];\n if (!existingTags.some((t) => codingMatches(t, tag))) {\n return {\n ...resource,\n meta: {\n ...resourceLike.meta,\n tag: [...existingTags, tag],\n },\n } as T;\n }\n }\n\n return resource;\n}\n\n/**\n * In ignore-tags mode: throws OystehrSdkError if any operation value resembles an ignored tag.\n * In tag-workspace mode: guards against removal or loss of the workspace tag:\n * - add/replace of the tag array: ensures workspace tag is present in the value\n * - add/replace of meta: ensures workspace tag is present in meta.tag\n * - remove of /meta/tag or /meta: keeps the remove and appends an operation to restore the workspace tag\n * - add of a single tag (path ends in /-): left unchanged (workspace tag already on the resource)\n */\nfunction applyTagToPatchOperations(config: OystehrConfig, operations: Operation[]): Operation[] {\n if (config.ignoreTags?.length) {\n for (const op of operations) {\n if (op.op === 'add' || op.op === 'replace' || op.op === 'test') {\n const opValue: unknown = op.value;\n if (opValue !== null && opValue !== undefined && typeof opValue === 'object') {\n const v = opValue as Coding;\n if (v.code !== undefined) {\n for (const ignored of config.ignoreTags) {\n if (codingMatches(v, ignored)) {\n throw new OystehrSdkError({\n message: `Patch operation contains an ignored tag (system: \"${ignored.system ?? ''}\", code: \"${\n ignored.code ?? ''\n }\") and cannot be applied in ignoreTags mode`,\n code: 400,\n });\n }\n }\n }\n }\n }\n }\n return operations;\n }\n\n if (config.workspaceTag) {\n const tag = config.workspaceTag;\n return operations.reduce<Operation[]>((result, op) => {\n // remove /meta/tag — restore workspace tag afterwards\n if (op.op === 'remove' && op.path === '/meta/tag') {\n result.push(op);\n result.push({ op: 'add' as const, path: '/meta/tag', value: [tag] });\n return result;\n }\n\n // remove /meta — restore workspace tag afterwards\n if (op.op === 'remove' && op.path === '/meta') {\n result.push(op);\n result.push({ op: 'add' as const, path: '/meta', value: { tag: [tag] } });\n return result;\n }\n\n // add/replace the entire tag array — ensure workspace tag is present\n if ((op.op === 'add' || op.op === 'replace') && op.path === '/meta/tag') {\n const tags: Coding[] = Array.isArray(op.value) ? (op.value as Coding[]) : [];\n if (!tags.some((t) => codingMatches(t, tag))) {\n result.push({ ...op, value: [...tags, tag] });\n } else {\n result.push(op);\n }\n return result;\n }\n\n // add/replace the entire meta object — ensure workspace tag is present in meta.tag\n if ((op.op === 'add' || op.op === 'replace') && op.path === '/meta') {\n const metaValue: { tag?: Coding[] } =\n op.value != null && typeof op.value === 'object' ? (op.value as { tag?: Coding[] }) : {};\n const tags = metaValue.tag ?? [];\n if (!tags.some((t) => codingMatches(t, tag))) {\n result.push({ ...op, value: { ...metaValue, tag: [...tags, tag] } });\n } else {\n result.push(op);\n }\n return result;\n }\n\n // All other operations (including add /meta/tag/- for individual tags) pass through unchanged.\n // Workspace tag is assumed already present on the resource from create/update.\n result.push(op);\n return result;\n }, []);\n }\n\n return operations;\n}\n\n/**\n * Throws OystehrFHIRError (404) if the retrieved resource violates the tag configuration:\n * - workspaceTag mode: resource must carry the workspace tag\n * - ignoreTags mode: resource must not carry any ignored tag\n */\nfunction assertRetrievedResource(config: OystehrConfig, resource: FhirResource): void {\n const resourceLike = resource as unknown as Resource;\n const resourceTags = (resourceLike.meta?.tag ?? []) as Coding[];\n\n if (config.workspaceTag) {\n const tag = config.workspaceTag;\n if (!resourceTags.some((t) => codingMatches(t, tag))) {\n throw new OystehrFHIRError({\n error: {\n resourceType: 'OperationOutcome',\n id: 'not-found',\n issue: [{ severity: 'error', code: 'not-found', details: { text: 'Not found' } }],\n },\n code: 404,\n });\n }\n return;\n }\n\n if (config.ignoreTags?.length) {\n for (const ignored of config.ignoreTags) {\n if (resourceTags.some((t) => codingMatches(t, ignored))) {\n throw new OystehrFHIRError({\n error: {\n resourceType: 'OperationOutcome',\n id: 'not-found',\n issue: [{ severity: 'error', code: 'not-found', details: { text: 'Not found' } }],\n },\n code: 404,\n });\n }\n }\n }\n}\n\n// ─────────────────────────────────────────────────────────────────────────────\n\n/**\n * Optional parameter that can be passed to the client methods. It allows\n * overriding the access token or project ID, and setting various headers,\n * such as 'Content-Type'. Also support enabling optimistic locking.\n */\nexport interface OystehrFHIRUpdateClientRequest extends OystehrClientRequest {\n /**\n * Enable optimistic locking for the request. If set to a version ID, the request will\n * include the 'If-Match' header with that value in the FHIR optimistic-locking format.\n * If the resource has been updated since the version provided, the request\n * will fail with a 412 Precondition Failed error.\n */\n optimisticLockingVersionId?: string;\n}\n\n/**\n * Performs a FHIR search and returns the results as a Bundle resource\n *\n * @param options FHIR resource type and FHIR search parameters\n * @param request optional OystehrClientRequest object\n * @returns FHIR Bundle resource\n */\nexport async function search<T extends FhirResource>(\n this: SDKResource,\n params: FhirSearchParams<T>,\n request?: OystehrClientRequest\n): Promise<FhirFetcherResponse<Bundle<T>>> {\n const { resourceType } = params;\n const taggedParams = applyTagSearchParams(this.config, params.params);\n let paramMap: Record<string, (string | number)[]> | undefined;\n if (taggedParams.length) {\n paramMap = taggedParams.reduce((acc, param) => {\n if (!acc[param.name]) {\n acc[param.name] = [];\n }\n acc[param.name].push(param.value);\n return acc;\n }, {} as Record<string, (string | number)[]>);\n }\n const requestBundle = await this.fhirRequest<FhirBundle<T>>(`/${resourceType}/_search`, 'POST')(paramMap, {\n ...request,\n contentType: 'application/x-www-form-urlencoded',\n });\n const bundle: Bundle<T> = {\n ...requestBundle,\n entry: requestBundle.entry as Array<BundleEntry<T>> | undefined,\n unbundle: function (this: { entry?: Array<BundleEntry<T>> | undefined }) {\n return (\n this.entry?.map((entry) => entry.resource).filter((resource): resource is T => resource !== undefined) ?? []\n );\n },\n };\n return bundle;\n}\n\nexport async function create<T extends FhirResource>(\n this: SDKResource,\n params: FhirCreateParams<T>,\n request?: OystehrClientRequest\n): Promise<FhirFetcherResponse<FhirResourceReturnValue<T>>> {\n const tagged = applyTagToResource(this.config, params);\n const { resourceType } = tagged;\n return this.fhirRequest(`/${resourceType}`, 'POST')(tagged as unknown as Record<string, unknown>, request);\n}\n\nexport async function get<T extends FhirResource>(\n this: SDKResource,\n { resourceType, id }: FhirGetParams<T>,\n request?: OystehrClientRequest\n): Promise<FhirFetcherResponse<FhirResourceReturnValue<T>>> {\n const result = await this.fhirRequest<FhirResourceReturnValue<T>>(`/${resourceType}/${id}`, 'GET')({}, request);\n assertRetrievedResource(this.config, result);\n return result;\n}\n\nexport async function update<T extends FhirResource>(\n this: SDKResource,\n params: FhirUpdateParams<T>,\n request?: OystehrFHIRUpdateClientRequest\n): Promise<FhirFetcherResponse<FhirResourceReturnValue<T>>> {\n const tagged = applyTagToResource(this.config, params);\n const { id, resourceType } = tagged;\n return this.fhirRequest(`/${resourceType}/${id}`, 'PUT')(tagged as unknown as Record<string, unknown>, {\n ...request,\n ifMatch: request?.optimisticLockingVersionId ? `W/\"${request.optimisticLockingVersionId}\"` : undefined,\n });\n}\n\nexport async function patch<T extends FhirResource>(\n this: SDKResource,\n { resourceType, id, operations }: FhirPatchParams<T>,\n request?: OystehrFHIRUpdateClientRequest\n): Promise<FhirFetcherResponse<FhirResourceReturnValue<T>>> {\n const taggedOperations = applyTagToPatchOperations(this.config, operations);\n return this.fhirRequest(`/${resourceType}/${id}`, 'PATCH')(taggedOperations, {\n ...request,\n contentType: 'application/json-patch+json',\n ifMatch: request?.optimisticLockingVersionId ? `W/\"${request.optimisticLockingVersionId}\"` : undefined,\n });\n}\n\nasync function del<T extends FhirResource>(\n this: SDKResource,\n { resourceType, id }: FhirDeleteParams<T>,\n request?: OystehrClientRequest\n): Promise<FhirFetcherResponse<FhirResourceReturnValue<T>>> {\n return this.fhirRequest(`/${resourceType}/${id}`, 'DELETE')({}, request);\n}\nexport { del as delete };\n\nexport async function history<T extends FhirResource>(\n this: SDKResource,\n { resourceType, id }: FhirHistorySearchParams<T>,\n request?: OystehrClientRequest\n): Promise<FhirFetcherResponse<Bundle<T>>>;\nexport async function history<T extends FhirResource>(\n this: SDKResource,\n { resourceType, id, versionId }: FhirHistoryGetParams<T>,\n request?: OystehrClientRequest\n): Promise<FhirFetcherResponse<T>>;\nexport async function history<T extends FhirResource>(\n this: SDKResource,\n { resourceType, id, count, offset }: FhirHistorySearchParams<T>,\n request?: OystehrClientRequest\n): Promise<FhirFetcherResponse<Bundle<T>>>;\nexport async function history<T extends FhirResource>(\n this: SDKResource,\n {\n resourceType,\n id,\n versionId,\n count,\n offset,\n }: { resourceType: string; id: string; versionId?: string; count?: number; offset?: number },\n request?: OystehrClientRequest\n): Promise<FhirFetcherResponse<Bundle<T>> | FhirFetcherResponse<T>> {\n if (versionId) {\n return this.fhirRequest(`/${resourceType}/${id}/_history/${versionId}`, 'GET')({}, request);\n }\n if (count) {\n return this.fhirRequest(\n `/${resourceType}/${id}/_history?_total=accurate&_count=${count}\n ${offset ? `&_offset=${offset}` : ''}`,\n 'GET'\n )({}, request);\n }\n return this.fhirRequest(`/${resourceType}/${id}/_history?_total=accurate`, 'GET')({}, request);\n}\n\n/**\n * Returns true when a batch GET/HEAD URL is a search (e.g. \"Patient\" or \"Patient?name=foo\")\n * rather than a direct retrieval (e.g. \"Patient/abc-123\").\n * A retrieval URL has a path segment after the resource type that is not a FHIR operation\n * (operations start with \"_\", e.g. \"_search\" or \"_history\").\n */\nfunction isBatchSearchUrl(url: string): boolean {\n const path = url.split('?')[0];\n const segments = path.split('/').filter(Boolean);\n // Only one segment → bare resource type, always a search\n if (segments.length <= 1) return true;\n // Two or more segments: second segment is an ID if it doesn't start with '_'\n return segments[1].startsWith('_');\n}\n\n/** Returns true when a batch POST URL targets a `_search` endpoint (e.g. \"Patient/_search\"). */\nfunction isBatchSearchPostUrl(url: string): boolean {\n return url.split('?')[0].endsWith('/_search');\n}\n\nfunction batchInputRequestToBundleEntryItem<T extends FhirResource>(\n request: BatchInputRequest<T>,\n config: OystehrConfig\n): BundleEntry<T | Binary<T>> {\n const { method } = request;\n let url = request.url;\n\n // Inject tag search params into search request URLs before URL encoding.\n // GET/HEAD: only for search URLs (not retrievals like Patient/<id>).\n // POST: only for _search endpoints (not creates).\n if (\n ((method === 'GET' || method === 'HEAD') && isBatchSearchUrl(url)) ||\n (method === 'POST' && isBatchSearchPostUrl(url))\n ) {\n if (config.workspaceTag) {\n url += (url.includes('?') ? '&' : '?') + `_tag=${codingToTagValue(config.workspaceTag)}`;\n }\n if (config.ignoreTags?.length) {\n for (const tag of config.ignoreTags) {\n url += (url.includes('?') ? '&' : '?') + `_tag:not=${codingToTagValue(tag)}`;\n }\n }\n }\n\n const baseRequest = {\n request: {\n method,\n url,\n },\n };\n\n // Escape query string parameters in entry.request.url\n if (url.split('?').length > 1) {\n const [resource, query] = url.split('?');\n const params = query\n .split('&')\n .map((param) => {\n const [name, value] = param.split('=');\n return { name, value };\n })\n .reduce((acc, { name, value }) => {\n if (!name) {\n return acc;\n }\n if (!acc[name]) {\n acc[name] = [];\n }\n acc[name].push(value);\n return acc;\n }, {} as Record<string, string[]>);\n const search = new URLSearchParams();\n addParamsToSearch(params, search);\n baseRequest.request.url = `${resource}?${search.toString()}`;\n }\n\n // GET, DELETE, and HEAD require no further parameters\n if (['GET', 'DELETE', 'HEAD'].includes(method)) {\n return baseRequest as BundleEntry<T>;\n }\n\n // PUT updates require a full resource\n if (method === 'PUT') {\n const resource = applyTagToResource(config, request.resource);\n return {\n request: {\n ...baseRequest.request,\n ifMatch: request.ifMatch,\n },\n resource: resource as T,\n } as BundleEntry<T>;\n }\n\n // PATCH can be Binary resource or JSON patch\n if (method === 'PATCH') {\n if ('resource' in request) {\n // Binary patch — decode operations, apply tag transforms, re-encode\n let patchResource = request.resource;\n const binaryData = patchResource.data;\n if (binaryData) {\n const operations = JSON.parse(base64ToString(binaryData)) as Operation[];\n const taggedOperations = applyTagToPatchOperations(config, operations);\n patchResource = { ...patchResource, data: stringToBase64(JSON.stringify(taggedOperations)) } as Binary<T>;\n }\n return {\n request: {\n ...baseRequest.request,\n ifMatch: request.ifMatch,\n },\n resource: patchResource,\n } as BundleEntry<Binary<T>>;\n }\n const operations = applyTagToPatchOperations(config, request.operations);\n const data = stringToBase64(JSON.stringify(operations));\n return {\n ...baseRequest,\n resource: {\n resourceType: 'Binary',\n contentType: 'application/json-patch+json',\n data,\n },\n } as BundleEntry<Binary<T>>;\n }\n\n // POST _search — no resource body; tag params were already injected into the URL above\n if (method === 'POST' && isBatchSearchPostUrl(url)) {\n return baseRequest as BundleEntry<T>;\n }\n\n // POST creates require a full resource\n if (method === 'POST' && 'resource' in request) {\n const resource = applyTagToResource(config, request.resource);\n const { fullUrl } = request;\n return {\n ...baseRequest,\n resource: resource as T,\n fullUrl,\n } as BundleEntry<T>;\n }\n\n // // Add ifMatch for the entries that support it\n // if ('ifMatch' in request) {\n // baseRequest.request = {\n // ...baseRequest.request,\n // ifMatch: request.ifMatch,\n // };\n // }\n\n throw new Error('Unrecognized method');\n}\n\nexport async function batch<BundleContentType extends FhirResource>(\n this: SDKResource,\n input: BatchInput<BundleContentType>,\n request?: OystehrClientRequest\n): Promise<FhirFetcherResponse<BatchBundle<BundleContentType>>> {\n const resp = await this.fhirRequest('/', 'POST')(\n {\n resourceType: 'Bundle',\n type: 'batch',\n entry: input.requests.map((req) => batchInputRequestToBundleEntryItem(req, this.config)),\n },\n request\n );\n // Validate each GET/HEAD retrieval entry against the tag config.\n // Violations are replaced with a synthetic 404 OperationOutcome entry; batch entries are independent.\n const rawEntries = resp.entry as Array<BundleEntry<BundleContentType>> | undefined;\n const processedEntries: Array<BundleEntry<BundleContentType>> | undefined =\n this.config.workspaceTag || this.config.ignoreTags?.length\n ? rawEntries?.map((entry, i) => {\n const req = input.requests[i];\n if (!req || !entry?.resource) return entry;\n if ((req.method === 'GET' || req.method === 'HEAD') && !isBatchSearchUrl(req.url)) {\n try {\n assertRetrievedResource(this.config, entry.resource);\n } catch (err) {\n if (!(err instanceof OystehrFHIRError)) throw err;\n return {\n request: entry.request,\n response: { status: '404', outcome: err.cause },\n } as unknown as BundleEntry<BundleContentType>;\n }\n }\n return entry;\n })\n : rawEntries;\n const bundle: BatchBundle<BundleContentType> = {\n ...resp,\n entry: processedEntries,\n unbundle: function (this: { entry?: Array<BundleEntry<BundleContentType>> | undefined }) {\n return (\n this.entry\n ?.map((entry) => entry.resource)\n .filter((resource): resource is BundleContentType => resource !== undefined) ?? []\n );\n },\n errors: function (this: { entry?: Array<BundleEntry<BundleContentType>> | undefined }) {\n return this.entry\n ?.filter((entry) => entry.response?.status?.startsWith('4') || entry.response?.status?.startsWith('5'))\n .map((entry) => entry.response?.outcome)\n .filter((outcome): outcome is OperationOutcome => outcome !== undefined);\n },\n };\n return bundle;\n}\n\nexport async function transaction<BundleContentType extends FhirResource>(\n this: SDKResource,\n input: BatchInput<BundleContentType>,\n request?: OystehrClientRequest\n): Promise<FhirFetcherResponse<TransactionBundle<BundleContentType>>> {\n const resp = await this.fhirRequest('/', 'POST')(\n {\n resourceType: 'Bundle',\n type: 'transaction',\n entry: input.requests.map((req) => batchInputRequestToBundleEntryItem(req, this.config)),\n },\n request\n );\n // Validate each GET/HEAD retrieval entry against the tag config.\n // A violation throws OystehrFHIRError(404) — transactions are all-or-nothing.\n if (this.config.workspaceTag || this.config.ignoreTags?.length) {\n (resp.entry as Array<BundleEntry<BundleContentType>> | undefined)?.forEach((entry, i) => {\n const req = input.requests[i];\n if (!req || !entry?.resource) return;\n if ((req.method === 'GET' || req.method === 'HEAD') && !isBatchSearchUrl(req.url)) {\n assertRetrievedResource(this.config, entry.resource);\n }\n });\n }\n const bundle: TransactionBundle<BundleContentType> = {\n ...resp,\n entry: resp.entry as Array<BundleEntry<BundleContentType>> | undefined,\n unbundle: function (this: { entry?: Array<BundleEntry<BundleContentType>> | undefined }) {\n return (\n this.entry\n ?.map((entry) => entry.resource)\n .filter((resource): resource is BundleContentType => resource !== undefined) ?? []\n );\n },\n };\n return bundle;\n}\n\nexport async function generateFriendlyPatientId(\n this: SDKResource,\n { id }: GenerateFriendlyPatientIdParams,\n request?: OystehrClientRequest\n): Promise<FhirFetcherResponse<FhirResource>> {\n return this.fhirRequest(`/Patient/${id}/$generate-friendly-patient-id`, 'POST')({}, request);\n}\n\nexport function formatAddress(\n address: AddressR4B | AddressR5,\n options?: { all?: boolean; use?: boolean; lineSeparator?: string }\n): string {\n const builder = [];\n\n if (address.line) {\n builder.push(...address.line);\n }\n\n if (address.city || address.state || address.postalCode) {\n const cityStateZip = [];\n if (address.city) {\n cityStateZip.push(address.city);\n }\n if (address.state) {\n cityStateZip.push(address.state);\n }\n if (address.postalCode) {\n cityStateZip.push(address.postalCode);\n }\n builder.push(cityStateZip.join(', '));\n }\n\n if (address.use && (options?.all || options?.use)) {\n builder.push('[' + address.use + ']');\n }\n\n return builder.join(options?.lineSeparator || ', ').trim();\n}\n\nexport function formatHumanName(\n name: HumanNameR4B | HumanNameR5,\n options?: {\n all?: boolean;\n prefix?: boolean;\n suffix?: boolean;\n use?: boolean;\n }\n): string {\n const builder = [];\n\n if (name.prefix && options?.prefix !== false) {\n builder.push(...name.prefix);\n }\n\n if (name.given) {\n builder.push(...name.given);\n }\n\n if (name.family) {\n builder.push(name.family);\n }\n\n if (name.suffix && options?.suffix !== false) {\n builder.push(...name.suffix);\n }\n\n if (name.use && (options?.all || options?.use)) {\n builder.push('[' + name.use + ']');\n }\n\n return builder.join(' ').trim();\n}\n"],"names":[],"mappings":";;;AAgCA;AACA,MAAM,cAAc,GAAG,MAAM;AAC7B,SAAS,cAAc,CAAC,KAAa,EAAA;AACnC,IAAA,MAAM,IAAI,GAA4B,IAAI,UAAU,CAAC,WAAW,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC;IAChF,IAAI,MAAM,GAAG,EAAE;AAEf,IAAA,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,IAAI,CAAC,MAAM,EAAE,KAAK,IAAI,cAAc,EAAE;AAChE,QAAA,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,KAAK,GAAG,cAAc,CAAC;;AAE1D,QAAA,MAAM,IAAI,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,SAAS,EAAE,KAA4B,CAAC,CAAC;IAChG;AACA,IAAA,OAAO,MAAM;AACf;AAEA,SAAS,cAAc,CAAC,KAAa,EAAA;IACnC,MAAM,YAAY,GAAG,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC;IAC3C,MAAM,KAAK,GAAG,IAAI,UAAU,CAAC,YAAY,CAAC,MAAM,CAAC;AACjD,IAAA,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,YAAY,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QAC5C,KAAK,CAAC,CAAC,CAAC,GAAG,YAAY,CAAC,UAAU,CAAC,CAAC,CAAC;IACvC;IACA,OAAO,IAAI,UAAU,CAAC,WAAW,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC;AACnD;AAEA;AAEA;AACA,SAAS,gBAAgB,CAAC,MAAc,EAAA;IACtC,OAAO,MAAM,CAAC,MAAM,GAAG,CAAA,EAAG,MAAM,CAAC,MAAM,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AAI,EAAE;AACjC;;;;"}
1
+ {"version":3,"file":"fhir-ext.js","sources":["../../../../src/resources/classes/fhir-ext.ts"],"sourcesContent":["import type { Operation } from 'fast-json-patch';\nimport { Address as AddressR4B, HumanName as HumanNameR4B } from 'fhir/r4b';\nimport { Address as AddressR5, HumanName as HumanNameR5 } from 'fhir/r5';\nimport {\n BatchBundle,\n BatchInput,\n BatchInputRequest,\n Binary,\n Bundle,\n BundleEntry,\n Coding,\n FhirAsyncJobHandle,\n FhirAsyncJobStatus,\n FhirAsyncWaitOptions,\n FhirBundle,\n FhirCreateParams,\n FhirDeleteParams,\n FhirGetParams,\n FhirHistoryGetParams,\n FhirHistorySearchParams,\n FhirPatchParams,\n FhirResource,\n FhirResourceReturnValue,\n FhirResponseMode,\n FhirSearchParams,\n FhirUpdateParams,\n GenerateFriendlyPatientIdParams,\n OperationOutcome,\n Resource,\n SearchParam,\n TransactionBundle,\n} from '../..';\nimport { addParamsToSearch, FhirFetcherResponse, OystehrClientRequest, SDKResource } from '../../client/client';\nimport { OystehrConfig } from '../../config';\nimport { OystehrFHIRError, OystehrSdkError } from '../../errors';\n\n// Code adapted from https://github.com/sindresorhus/uint8array-extras\nconst MAX_BLOCK_SIZE = 65_535;\nfunction stringToBase64(input: string): string {\n const data: Uint8Array<ArrayBuffer> = new globalThis.TextEncoder().encode(input);\n let base64 = '';\n\n for (let index = 0; index < data.length; index += MAX_BLOCK_SIZE) {\n const chunk = data.subarray(index, index + MAX_BLOCK_SIZE);\n // Required as `btoa` and `atob` don't properly support Unicode: https://developer.mozilla.org/en-US/docs/Glossary/Base64#the_unicode_problem\n base64 += globalThis.btoa(String.fromCodePoint.apply(undefined, chunk as unknown as number[]));\n }\n return base64;\n}\n\nfunction base64ToString(input: string): string {\n const binaryString = globalThis.atob(input);\n const bytes = new Uint8Array(binaryString.length);\n for (let i = 0; i < binaryString.length; i++) {\n bytes[i] = binaryString.charCodeAt(i);\n }\n return new globalThis.TextDecoder().decode(bytes);\n}\n\n// ─── Tag-mode helpers ────────────────────────────────────────────────────────\n\n/** Converts a Coding to the FHIR _tag parameter value format \"system|code\". */\nfunction codingToTagValue(coding: Coding): string {\n return coding.system ? `${coding.system}|${coding.code ?? ''}` : coding.code ?? '';\n}\n\n/** Returns true if two Codings match on system (treating absent as empty string) and code. */\nfunction codingMatches(a: Coding, b: Coding): boolean {\n return (a.system ?? '') === (b.system ?? '') && (a.code ?? '') === (b.code ?? '');\n}\n\n/**\n * Appends _tag (tag-workspace mode) or _tag:not (ignore-tags mode) search\n * params to an existing SearchParam array and returns the new array.\n */\nfunction applyTagSearchParams(config: OystehrConfig, params: SearchParam[] | undefined): SearchParam[] {\n const out: SearchParam[] = params ? [...params] : [];\n if (config.workspaceTag) {\n out.push({ name: '_tag', value: codingToTagValue(config.workspaceTag) });\n } else if (config.ignoreTags?.length) {\n for (const tag of config.ignoreTags) {\n out.push({ name: '_tag:not', value: codingToTagValue(tag) });\n }\n }\n return out;\n}\n\n/**\n * In ignore-tags mode: throws OystehrSdkError if the resource carries any ignored tag.\n * In tag-workspace mode: injects the workspace tag into resource.meta.tag if not already present.\n * Returns the (possibly cloned) resource.\n */\nfunction applyTagToResource<T extends FhirResource>(config: OystehrConfig, resource: T): T {\n const resourceLike = resource as unknown as Resource;\n\n if (config.ignoreTags?.length) {\n const resourceTags = (resourceLike.meta?.tag ?? []) as Coding[];\n for (const ignored of config.ignoreTags) {\n if (resourceTags.some((t) => codingMatches(t, ignored))) {\n throw new OystehrSdkError({\n message: `Resource has an ignored tag (system: \"${ignored.system ?? ''}\", code: \"${\n ignored.code ?? ''\n }\") and cannot be mutated in ignoreTags mode`,\n code: 400,\n });\n }\n }\n return resource;\n }\n\n if (config.workspaceTag) {\n const tag = config.workspaceTag;\n const existingTags = (resourceLike.meta?.tag ?? []) as Coding[];\n if (!existingTags.some((t) => codingMatches(t, tag))) {\n return {\n ...resource,\n meta: {\n ...resourceLike.meta,\n tag: [...existingTags, tag],\n },\n } as T;\n }\n }\n\n return resource;\n}\n\n/**\n * In ignore-tags mode: throws OystehrSdkError if any operation value resembles an ignored tag.\n * In tag-workspace mode: guards against removal or loss of the workspace tag:\n * - add/replace of the tag array: ensures workspace tag is present in the value\n * - add/replace of meta: ensures workspace tag is present in meta.tag\n * - remove of /meta/tag or /meta: keeps the remove and appends an operation to restore the workspace tag\n * - add of a single tag (path ends in /-): left unchanged (workspace tag already on the resource)\n */\nfunction applyTagToPatchOperations(config: OystehrConfig, operations: Operation[]): Operation[] {\n if (config.ignoreTags?.length) {\n for (const op of operations) {\n if (op.op === 'add' || op.op === 'replace' || op.op === 'test') {\n const opValue: unknown = op.value;\n if (opValue !== null && opValue !== undefined && typeof opValue === 'object') {\n const v = opValue as Coding;\n if (v.code !== undefined) {\n for (const ignored of config.ignoreTags) {\n if (codingMatches(v, ignored)) {\n throw new OystehrSdkError({\n message: `Patch operation contains an ignored tag (system: \"${ignored.system ?? ''}\", code: \"${\n ignored.code ?? ''\n }\") and cannot be applied in ignoreTags mode`,\n code: 400,\n });\n }\n }\n }\n }\n }\n }\n return operations;\n }\n\n if (config.workspaceTag) {\n const tag = config.workspaceTag;\n return operations.reduce<Operation[]>((result, op) => {\n // remove /meta/tag — restore workspace tag afterwards\n if (op.op === 'remove' && op.path === '/meta/tag') {\n result.push(op);\n result.push({ op: 'add' as const, path: '/meta/tag', value: [tag] });\n return result;\n }\n\n // remove /meta — restore workspace tag afterwards\n if (op.op === 'remove' && op.path === '/meta') {\n result.push(op);\n result.push({ op: 'add' as const, path: '/meta', value: { tag: [tag] } });\n return result;\n }\n\n // add/replace the entire tag array — ensure workspace tag is present\n if ((op.op === 'add' || op.op === 'replace') && op.path === '/meta/tag') {\n const tags: Coding[] = Array.isArray(op.value) ? (op.value as Coding[]) : [];\n if (!tags.some((t) => codingMatches(t, tag))) {\n result.push({ ...op, value: [...tags, tag] });\n } else {\n result.push(op);\n }\n return result;\n }\n\n // add/replace the entire meta object — ensure workspace tag is present in meta.tag\n if ((op.op === 'add' || op.op === 'replace') && op.path === '/meta') {\n const metaValue: { tag?: Coding[] } =\n op.value != null && typeof op.value === 'object' ? (op.value as { tag?: Coding[] }) : {};\n const tags = metaValue.tag ?? [];\n if (!tags.some((t) => codingMatches(t, tag))) {\n result.push({ ...op, value: { ...metaValue, tag: [...tags, tag] } });\n } else {\n result.push(op);\n }\n return result;\n }\n\n // All other operations (including add /meta/tag/- for individual tags) pass through unchanged.\n // Workspace tag is assumed already present on the resource from create/update.\n result.push(op);\n return result;\n }, []);\n }\n\n return operations;\n}\n\n/**\n * Throws OystehrFHIRError (404) if the retrieved resource violates the tag configuration:\n * - workspaceTag mode: resource must carry the workspace tag\n * - ignoreTags mode: resource must not carry any ignored tag\n */\nfunction assertRetrievedResource(config: OystehrConfig, resource: FhirResource): void {\n const resourceLike = resource as unknown as Resource;\n const resourceTags = (resourceLike.meta?.tag ?? []) as Coding[];\n\n if (config.workspaceTag) {\n const tag = config.workspaceTag;\n if (!resourceTags.some((t) => codingMatches(t, tag))) {\n throw new OystehrFHIRError({\n error: {\n resourceType: 'OperationOutcome',\n id: 'not-found',\n issue: [{ severity: 'error', code: 'not-found', details: { text: 'Not found' } }],\n },\n code: 404,\n });\n }\n return;\n }\n\n if (config.ignoreTags?.length) {\n for (const ignored of config.ignoreTags) {\n if (resourceTags.some((t) => codingMatches(t, ignored))) {\n throw new OystehrFHIRError({\n error: {\n resourceType: 'OperationOutcome',\n id: 'not-found',\n issue: [{ severity: 'error', code: 'not-found', details: { text: 'Not found' } }],\n },\n code: 404,\n });\n }\n }\n }\n}\n\n// ─────────────────────────────────────────────────────────────────────────────\n\n/**\n * Optional parameter that can be passed to the client methods. It allows\n * overriding the access token or project ID, and setting various headers,\n * such as 'Content-Type'. Also support enabling optimistic locking.\n */\nexport interface OystehrFHIRUpdateClientRequest extends OystehrClientRequest {\n /**\n * Enable optimistic locking for the request. If set to a version ID, the request will\n * include the 'If-Match' header with that value in the FHIR optimistic-locking format.\n * If the resource has been updated since the version provided, the request\n * will fail with a 412 Precondition Failed error.\n */\n optimisticLockingVersionId?: string;\n}\n\nfunction isAsyncRequestMode(mode: FhirResponseMode | undefined): mode is Exclude<FhirResponseMode, 'sync'> {\n return mode === 'async-bundle' || mode === 'async-bulk';\n}\n\n/**\n * Performs a FHIR search and returns the results as a Bundle resource\n *\n * @param options FHIR resource type and FHIR search parameters\n * @param request optional OystehrClientRequest object\n * @returns FHIR Bundle resource\n */\nexport async function search<T extends FhirResource>(\n this: SDKResource,\n params: FhirSearchParams<T>,\n request: OystehrClientRequest & { mode: Exclude<FhirResponseMode, 'sync'> }\n): Promise<FhirAsyncJobHandle>;\nexport async function search<T extends FhirResource>(\n this: SDKResource,\n params: FhirSearchParams<T>,\n request?: OystehrClientRequest & { mode?: 'sync' | undefined }\n): Promise<FhirFetcherResponse<Bundle<T>>>;\nexport async function search<T extends FhirResource>(\n this: SDKResource,\n params: FhirSearchParams<T>,\n request?: OystehrClientRequest\n): Promise<FhirFetcherResponse<Bundle<T>> | FhirAsyncJobHandle> {\n const { resourceType } = params;\n const taggedParams = applyTagSearchParams(this.config, params.params);\n let paramMap: Record<string, (string | number)[]> | undefined;\n if (taggedParams.length) {\n paramMap = taggedParams.reduce((acc, param) => {\n if (!acc[param.name]) {\n acc[param.name] = [];\n }\n acc[param.name].push(param.value);\n return acc;\n }, {} as Record<string, (string | number)[]>);\n }\n\n const requestMode = request?.mode;\n if (isAsyncRequestMode(requestMode)) {\n return await this.startAsyncJob(`/${resourceType}/_search`, 'POST', paramMap ?? {}, requestMode, {\n ...request,\n contentType: 'application/x-www-form-urlencoded',\n });\n }\n\n const requestBundle = await this.fhirRequest<FhirBundle<T>>(`/${resourceType}/_search`, 'POST')(paramMap, {\n ...request,\n contentType: 'application/x-www-form-urlencoded',\n });\n const bundle: Bundle<T> = {\n ...requestBundle,\n entry: requestBundle.entry as Array<BundleEntry<T>> | undefined,\n unbundle: function (this: { entry?: Array<BundleEntry<T>> | undefined }) {\n return (\n this.entry?.map((entry) => entry.resource).filter((resource): resource is T => resource !== undefined) ?? []\n );\n },\n };\n return bundle;\n}\n\nexport async function create<T extends FhirResource>(\n this: SDKResource,\n params: FhirCreateParams<T>,\n request: OystehrClientRequest & { mode: Exclude<FhirResponseMode, 'sync'> }\n): Promise<FhirAsyncJobHandle>;\nexport async function create<T extends FhirResource>(\n this: SDKResource,\n params: FhirCreateParams<T>,\n request?: OystehrClientRequest & { mode?: 'sync' | undefined }\n): Promise<FhirFetcherResponse<FhirResourceReturnValue<T>>>;\nexport async function create<T extends FhirResource>(\n this: SDKResource,\n params: FhirCreateParams<T>,\n request?: OystehrClientRequest\n): Promise<FhirFetcherResponse<FhirResourceReturnValue<T>> | FhirAsyncJobHandle> {\n const tagged = applyTagToResource(this.config, params);\n const { resourceType } = tagged;\n const requestMode = request?.mode;\n if (isAsyncRequestMode(requestMode)) {\n return await this.startAsyncJob(\n `/${resourceType}`,\n 'POST',\n tagged as unknown as Record<string, unknown>,\n requestMode,\n request\n );\n }\n\n return await this.fhirRequest<FhirResourceReturnValue<T>>(`/${resourceType}`, 'POST')(\n tagged as unknown as Record<string, unknown>,\n request\n );\n}\n\nexport async function get<T extends FhirResource>(\n this: SDKResource,\n { resourceType, id }: FhirGetParams<T>,\n request: OystehrClientRequest & { mode: Exclude<FhirResponseMode, 'sync'> }\n): Promise<FhirAsyncJobHandle>;\nexport async function get<T extends FhirResource>(\n this: SDKResource,\n { resourceType, id }: FhirGetParams<T>,\n request?: OystehrClientRequest & { mode?: 'sync' | undefined }\n): Promise<FhirFetcherResponse<FhirResourceReturnValue<T>>>;\nexport async function get<T extends FhirResource>(\n this: SDKResource,\n { resourceType, id }: FhirGetParams<T>,\n request?: OystehrClientRequest\n): Promise<FhirFetcherResponse<FhirResourceReturnValue<T>> | FhirAsyncJobHandle> {\n const requestMode = request?.mode;\n if (isAsyncRequestMode(requestMode)) {\n return await this.startAsyncJob(`/${resourceType}/${id}`, 'GET', {}, requestMode, request);\n }\n\n const result = await this.fhirRequest<FhirResourceReturnValue<T>>(`/${resourceType}/${id}`, 'GET')({}, request);\n assertRetrievedResource(this.config, result);\n return result;\n}\n\nexport async function update<T extends FhirResource>(\n this: SDKResource,\n params: FhirUpdateParams<T>,\n request: OystehrFHIRUpdateClientRequest & { mode: Exclude<FhirResponseMode, 'sync'> }\n): Promise<FhirAsyncJobHandle>;\nexport async function update<T extends FhirResource>(\n this: SDKResource,\n params: FhirUpdateParams<T>,\n request?: OystehrFHIRUpdateClientRequest & { mode?: 'sync' | undefined }\n): Promise<FhirFetcherResponse<FhirResourceReturnValue<T>>>;\nexport async function update<T extends FhirResource>(\n this: SDKResource,\n params: FhirUpdateParams<T>,\n request?: OystehrFHIRUpdateClientRequest\n): Promise<FhirFetcherResponse<FhirResourceReturnValue<T>> | FhirAsyncJobHandle> {\n const tagged = applyTagToResource(this.config, params);\n const { id, resourceType } = tagged;\n const requestMode = request?.mode;\n const ifMatchRequest = {\n ...request,\n ifMatch: request?.optimisticLockingVersionId ? `W/\"${request.optimisticLockingVersionId}\"` : undefined,\n };\n\n if (isAsyncRequestMode(requestMode)) {\n return await this.startAsyncJob(\n `/${resourceType}/${id}`,\n 'PUT',\n tagged as unknown as Record<string, unknown>,\n requestMode,\n ifMatchRequest\n );\n }\n\n return await this.fhirRequest<FhirResourceReturnValue<T>>(`/${resourceType}/${id}`, 'PUT')(\n tagged as unknown as Record<string, unknown>,\n ifMatchRequest\n );\n}\n\nexport async function patch<T extends FhirResource>(\n this: SDKResource,\n params: FhirPatchParams<T>,\n request: OystehrFHIRUpdateClientRequest & { mode: Exclude<FhirResponseMode, 'sync'> }\n): Promise<FhirAsyncJobHandle>;\nexport async function patch<T extends FhirResource>(\n this: SDKResource,\n params: FhirPatchParams<T>,\n request?: OystehrFHIRUpdateClientRequest & { mode?: 'sync' | undefined }\n): Promise<FhirFetcherResponse<FhirResourceReturnValue<T>>>;\nexport async function patch<T extends FhirResource>(\n this: SDKResource,\n { resourceType, id, operations }: FhirPatchParams<T>,\n request?: OystehrFHIRUpdateClientRequest\n): Promise<FhirFetcherResponse<FhirResourceReturnValue<T>> | FhirAsyncJobHandle> {\n const taggedOperations = applyTagToPatchOperations(this.config, operations);\n const requestMode = request?.mode;\n const ifMatchRequest = {\n ...request,\n ifMatch: request?.optimisticLockingVersionId ? `W/\"${request.optimisticLockingVersionId}\"` : undefined,\n };\n\n if (isAsyncRequestMode(requestMode)) {\n return await this.startAsyncJob(\n `/${resourceType}/${id}`,\n 'PATCH',\n taggedOperations as unknown as Record<string, unknown>,\n requestMode,\n {\n ...ifMatchRequest,\n contentType: 'application/json-patch+json',\n }\n );\n }\n\n return this.fhirRequest<FhirResourceReturnValue<T>>(`/${resourceType}/${id}`, 'PATCH')(taggedOperations, {\n ...ifMatchRequest,\n contentType: 'application/json-patch+json',\n });\n}\n\nasync function del<T extends FhirResource>(\n this: SDKResource,\n params: FhirDeleteParams<T>,\n request: OystehrClientRequest & { mode: Exclude<FhirResponseMode, 'sync'> }\n): Promise<FhirAsyncJobHandle>;\nasync function del<T extends FhirResource>(\n this: SDKResource,\n params: FhirDeleteParams<T>,\n request?: OystehrClientRequest & { mode?: 'sync' | undefined }\n): Promise<FhirFetcherResponse<FhirResourceReturnValue<T>>>;\nasync function del<T extends FhirResource>(\n this: SDKResource,\n { resourceType, id }: FhirDeleteParams<T>,\n request?: OystehrClientRequest\n): Promise<FhirFetcherResponse<FhirResourceReturnValue<T>> | FhirAsyncJobHandle> {\n const requestMode = request?.mode;\n if (isAsyncRequestMode(requestMode)) {\n return await this.startAsyncJob(`/${resourceType}/${id}`, 'DELETE', {}, requestMode, request);\n }\n\n return await this.fhirRequest<FhirResourceReturnValue<T>>(`/${resourceType}/${id}`, 'DELETE')({}, request);\n}\nexport { del as delete };\n\nfunction getRetryDelayMs(retryAfter: string | undefined, fallbackMs: number): number {\n if (!retryAfter) {\n return fallbackMs;\n }\n\n const asSeconds = Number(retryAfter);\n if (Number.isFinite(asSeconds) && asSeconds >= 0) {\n return Math.max(0, Math.floor(asSeconds * 1000));\n }\n\n const asTimestamp = Date.parse(retryAfter);\n if (Number.isFinite(asTimestamp)) {\n return Math.max(0, asTimestamp - Date.now());\n }\n\n return fallbackMs;\n}\n\nexport async function getAsyncJob<T extends FhirResource>(\n this: SDKResource,\n jobId: string,\n request?: OystehrClientRequest\n): Promise<FhirAsyncJobStatus<T>> {\n return await this.fetchAsyncJobStatus<T>(jobId, request);\n}\n\nexport async function waitForAsyncJob<T extends FhirResource>(\n this: SDKResource,\n jobId: string,\n options?: FhirAsyncWaitOptions,\n request?: OystehrClientRequest\n): Promise<FhirAsyncJobStatus<T>> {\n // 5 seconds poll interval by default\n const pollIntervalMs = options?.pollIntervalMs ?? 5000;\n // 15 minutes timout by default\n const timeoutMs = options?.timeoutMs ?? 900000;\n const attempts = Math.max(1, Math.ceil(timeoutMs / pollIntervalMs));\n\n for (let attempt = 0; attempt < attempts; attempt++) {\n const status = await this.fetchAsyncJobStatus<T>(jobId, request);\n if (status.status !== 202) {\n return status;\n }\n\n if (attempt < attempts - 1) {\n const retryAfter = 'retryAfter' in status ? status.retryAfter : undefined;\n await new Promise((resolve) => setTimeout(resolve, getRetryDelayMs(retryAfter, pollIntervalMs)));\n }\n }\n\n throw new OystehrSdkError({\n message: `Async job ${jobId} did not complete within ${timeoutMs} ms`,\n code: 408,\n });\n}\n\nexport async function cancelAsyncJob(this: SDKResource, jobId: string, request?: OystehrClientRequest): Promise<void> {\n await this.fhirRequest(`/async-job/${jobId}`, 'DELETE')({}, request);\n}\n\nexport async function history<T extends FhirResource>(\n this: SDKResource,\n { resourceType, id }: FhirHistorySearchParams<T>,\n request: OystehrClientRequest & { mode: Exclude<FhirResponseMode, 'sync'> }\n): Promise<FhirAsyncJobHandle>;\nexport async function history<T extends FhirResource>(\n this: SDKResource,\n { resourceType, id, versionId }: FhirHistoryGetParams<T>,\n request: OystehrClientRequest & { mode: Exclude<FhirResponseMode, 'sync'> }\n): Promise<FhirAsyncJobHandle>;\nexport async function history<T extends FhirResource>(\n this: SDKResource,\n { resourceType, id, versionId }: FhirHistoryGetParams<T>,\n request?: OystehrClientRequest & { mode?: 'sync' | undefined }\n): Promise<FhirFetcherResponse<T>>;\nexport async function history<T extends FhirResource>(\n this: SDKResource,\n { resourceType, id }: FhirHistorySearchParams<T>,\n request?: OystehrClientRequest & { mode?: 'sync' | undefined }\n): Promise<FhirFetcherResponse<Bundle<T>>>;\nexport async function history<T extends FhirResource>(\n this: SDKResource,\n { resourceType, id, count, offset }: FhirHistorySearchParams<T>,\n request?: OystehrClientRequest & { mode?: 'sync' | undefined }\n): Promise<FhirFetcherResponse<Bundle<T>>>;\n\nexport async function history<T extends FhirResource>(\n this: SDKResource,\n {\n resourceType,\n id,\n versionId,\n count,\n offset,\n }: { resourceType: string; id: string; versionId?: string; count?: number; offset?: number },\n request?: OystehrClientRequest\n): Promise<FhirFetcherResponse<Bundle<T>> | FhirFetcherResponse<T> | FhirAsyncJobHandle> {\n const requestMode = request?.mode;\n if (isAsyncRequestMode(requestMode)) {\n if (versionId) {\n return await this.startAsyncJob(`/${resourceType}/${id}/_history/${versionId}`, 'GET', {}, requestMode, request);\n }\n return await this.startAsyncJob(`/${resourceType}/${id}/_history`, 'GET', {}, requestMode, request);\n }\n\n if (versionId) {\n return this.fhirRequest<T>(`/${resourceType}/${id}/_history/${versionId}`, 'GET')({}, request);\n }\n if (count) {\n return this.fhirRequest<Bundle<T>>(\n `/${resourceType}/${id}/_history?_total=accurate&_count=${count}\n ${offset ? `&_offset=${offset}` : ''}`,\n 'GET'\n )({}, request);\n }\n return this.fhirRequest<Bundle<T>>(`/${resourceType}/${id}/_history?_total=accurate`, 'GET')({}, request);\n}\n\n/**\n * Returns true when a batch GET/HEAD URL is a search (e.g. \"Patient\" or \"Patient?name=foo\")\n * rather than a direct retrieval (e.g. \"Patient/abc-123\").\n * A retrieval URL has a path segment after the resource type that is not a FHIR operation\n * (operations start with \"_\", e.g. \"_search\" or \"_history\").\n */\nfunction isBatchSearchUrl(url: string): boolean {\n const path = url.split('?')[0];\n const segments = path.split('/').filter(Boolean);\n // Only one segment → bare resource type, always a search\n if (segments.length <= 1) return true;\n // Two or more segments: second segment is an ID if it doesn't start with '_'\n return segments[1].startsWith('_');\n}\n\n/** Returns true when a batch POST URL targets a `_search` endpoint (e.g. \"Patient/_search\"). */\nfunction isBatchSearchPostUrl(url: string): boolean {\n return url.split('?')[0].endsWith('/_search');\n}\n\nfunction batchInputRequestToBundleEntryItem<T extends FhirResource>(\n request: BatchInputRequest<T>,\n config: OystehrConfig\n): BundleEntry<T | Binary<T>> {\n const { method } = request;\n let url = request.url;\n\n // Inject tag search params into search request URLs before URL encoding.\n // GET/HEAD: only for search URLs (not retrievals like Patient/<id>).\n // POST: only for _search endpoints (not creates).\n if (\n ((method === 'GET' || method === 'HEAD') && isBatchSearchUrl(url)) ||\n (method === 'POST' && isBatchSearchPostUrl(url))\n ) {\n if (config.workspaceTag) {\n url += (url.includes('?') ? '&' : '?') + `_tag=${codingToTagValue(config.workspaceTag)}`;\n }\n if (config.ignoreTags?.length) {\n for (const tag of config.ignoreTags) {\n url += (url.includes('?') ? '&' : '?') + `_tag:not=${codingToTagValue(tag)}`;\n }\n }\n }\n\n const baseRequest = {\n request: {\n method,\n url,\n },\n };\n\n // Escape query string parameters in entry.request.url\n if (url.split('?').length > 1) {\n const [resource, query] = url.split('?');\n const params = query\n .split('&')\n .map((param) => {\n const [name, value] = param.split('=');\n return { name, value };\n })\n .reduce((acc, { name, value }) => {\n if (!name) {\n return acc;\n }\n if (!acc[name]) {\n acc[name] = [];\n }\n acc[name].push(value);\n return acc;\n }, {} as Record<string, string[]>);\n const search = new URLSearchParams();\n addParamsToSearch(params, search);\n baseRequest.request.url = `${resource}?${search.toString()}`;\n }\n\n // GET, DELETE, and HEAD require no further parameters\n if (['GET', 'DELETE', 'HEAD'].includes(method)) {\n return baseRequest as BundleEntry<T>;\n }\n\n // PUT updates require a full resource\n if (method === 'PUT') {\n const resource = applyTagToResource(config, request.resource);\n return {\n request: {\n ...baseRequest.request,\n ifMatch: request.ifMatch,\n },\n resource: resource as T,\n } as BundleEntry<T>;\n }\n\n // PATCH can be Binary resource or JSON patch\n if (method === 'PATCH') {\n if ('resource' in request) {\n // Binary patch — decode operations, apply tag transforms, re-encode\n let patchResource = request.resource;\n const binaryData = patchResource.data;\n if (binaryData) {\n const operations = JSON.parse(base64ToString(binaryData)) as Operation[];\n const taggedOperations = applyTagToPatchOperations(config, operations);\n patchResource = { ...patchResource, data: stringToBase64(JSON.stringify(taggedOperations)) } as Binary<T>;\n }\n return {\n request: {\n ...baseRequest.request,\n ifMatch: request.ifMatch,\n },\n resource: patchResource,\n } as BundleEntry<Binary<T>>;\n }\n const operations = applyTagToPatchOperations(config, request.operations);\n const data = stringToBase64(JSON.stringify(operations));\n return {\n ...baseRequest,\n resource: {\n resourceType: 'Binary',\n contentType: 'application/json-patch+json',\n data,\n },\n } as BundleEntry<Binary<T>>;\n }\n\n // POST _search — no resource body; tag params were already injected into the URL above\n if (method === 'POST' && isBatchSearchPostUrl(url)) {\n return baseRequest as BundleEntry<T>;\n }\n\n // POST creates require a full resource\n if (method === 'POST' && 'resource' in request) {\n const resource = applyTagToResource(config, request.resource);\n const { fullUrl } = request;\n return {\n ...baseRequest,\n resource: resource as T,\n fullUrl,\n } as BundleEntry<T>;\n }\n\n // // Add ifMatch for the entries that support it\n // if ('ifMatch' in request) {\n // baseRequest.request = {\n // ...baseRequest.request,\n // ifMatch: request.ifMatch,\n // };\n // }\n\n throw new Error('Unrecognized method');\n}\n\nexport async function batch<BundleContentType extends FhirResource>(\n this: SDKResource,\n input: BatchInput<BundleContentType>,\n request: OystehrClientRequest & { mode: Exclude<FhirResponseMode, 'sync'> }\n): Promise<FhirAsyncJobHandle>;\nexport async function batch<BundleContentType extends FhirResource>(\n this: SDKResource,\n input: BatchInput<BundleContentType>,\n request?: OystehrClientRequest & { mode?: 'sync' | undefined }\n): Promise<FhirFetcherResponse<BatchBundle<BundleContentType>>>;\nexport async function batch<BundleContentType extends FhirResource>(\n this: SDKResource,\n input: BatchInput<BundleContentType>,\n request?: OystehrClientRequest\n): Promise<FhirFetcherResponse<BatchBundle<BundleContentType>> | FhirAsyncJobHandle> {\n const requestPayload = {\n resourceType: 'Bundle',\n type: 'batch',\n entry: input.requests.map((req) => batchInputRequestToBundleEntryItem(req, this.config)),\n };\n const requestMode = request?.mode;\n if (isAsyncRequestMode(requestMode)) {\n return await this.startAsyncJob('/', 'POST', requestPayload, requestMode, request);\n }\n\n const resp = await this.fhirRequest<BatchBundle<BundleContentType>>('/', 'POST')(requestPayload, request);\n // Validate each GET/HEAD retrieval entry against the tag config.\n // Violations are replaced with a synthetic 404 OperationOutcome entry; batch entries are independent.\n const rawEntries = resp.entry as Array<BundleEntry<BundleContentType>> | undefined;\n const processedEntries: Array<BundleEntry<BundleContentType>> | undefined =\n this.config.workspaceTag || this.config.ignoreTags?.length\n ? rawEntries?.map((entry, i) => {\n const req = input.requests[i];\n if (!req || !entry?.resource) return entry;\n if ((req.method === 'GET' || req.method === 'HEAD') && !isBatchSearchUrl(req.url)) {\n try {\n assertRetrievedResource(this.config, entry.resource);\n } catch (err) {\n if (!(err instanceof OystehrFHIRError)) throw err;\n return {\n request: entry.request,\n response: { status: '404', outcome: err.cause },\n } as unknown as BundleEntry<BundleContentType>;\n }\n }\n return entry;\n })\n : rawEntries;\n const bundle: BatchBundle<BundleContentType> = {\n ...resp,\n entry: processedEntries,\n unbundle: function (this: { entry?: Array<BundleEntry<BundleContentType>> | undefined }) {\n return (\n this.entry\n ?.map((entry) => entry.resource)\n .filter((resource): resource is BundleContentType => resource !== undefined) ?? []\n );\n },\n errors: function (this: { entry?: Array<BundleEntry<BundleContentType>> | undefined }) {\n return this.entry\n ?.filter((entry) => entry.response?.status?.startsWith('4') || entry.response?.status?.startsWith('5'))\n .map((entry) => entry.response?.outcome)\n .filter((outcome): outcome is OperationOutcome => outcome !== undefined);\n },\n };\n return bundle;\n}\n\nexport async function transaction<BundleContentType extends FhirResource>(\n this: SDKResource,\n input: BatchInput<BundleContentType>,\n request: OystehrClientRequest & { mode: Exclude<FhirResponseMode, 'sync'> }\n): Promise<FhirAsyncJobHandle>;\nexport async function transaction<BundleContentType extends FhirResource>(\n this: SDKResource,\n input: BatchInput<BundleContentType>,\n request?: OystehrClientRequest & { mode?: 'sync' | undefined }\n): Promise<FhirFetcherResponse<TransactionBundle<BundleContentType>>>;\nexport async function transaction<BundleContentType extends FhirResource>(\n this: SDKResource,\n input: BatchInput<BundleContentType>,\n request?: OystehrClientRequest\n): Promise<FhirFetcherResponse<TransactionBundle<BundleContentType>> | FhirAsyncJobHandle> {\n const requestPayload = {\n resourceType: 'Bundle',\n type: 'transaction',\n entry: input.requests.map((req) => batchInputRequestToBundleEntryItem(req, this.config)),\n };\n const requestMode = request?.mode;\n if (isAsyncRequestMode(requestMode)) {\n return await this.startAsyncJob('/', 'POST', requestPayload, requestMode, request);\n }\n\n const resp = await this.fhirRequest<TransactionBundle<BundleContentType>>('/', 'POST')(requestPayload, request);\n // Validate each GET/HEAD retrieval entry against the tag config.\n // A violation throws OystehrFHIRError(404) — transactions are all-or-nothing.\n if (this.config.workspaceTag || this.config.ignoreTags?.length) {\n (resp.entry as Array<BundleEntry<BundleContentType>> | undefined)?.forEach((entry, i) => {\n const req = input.requests[i];\n if (!req || !entry?.resource) return;\n if ((req.method === 'GET' || req.method === 'HEAD') && !isBatchSearchUrl(req.url)) {\n assertRetrievedResource(this.config, entry.resource);\n }\n });\n }\n const bundle: TransactionBundle<BundleContentType> = {\n ...resp,\n entry: resp.entry as Array<BundleEntry<BundleContentType>> | undefined,\n unbundle: function (this: { entry?: Array<BundleEntry<BundleContentType>> | undefined }) {\n return (\n this.entry\n ?.map((entry) => entry.resource)\n .filter((resource): resource is BundleContentType => resource !== undefined) ?? []\n );\n },\n };\n return bundle;\n}\n\nexport async function generateFriendlyPatientId(\n this: SDKResource,\n { id }: GenerateFriendlyPatientIdParams,\n request?: OystehrClientRequest\n): Promise<FhirFetcherResponse<FhirResource>> {\n return this.fhirRequest(`/Patient/${id}/$generate-friendly-patient-id`, 'POST')({}, request);\n}\n\nexport function formatAddress(\n address: AddressR4B | AddressR5,\n options?: { all?: boolean; use?: boolean; lineSeparator?: string }\n): string {\n const builder = [];\n\n if (address.line) {\n builder.push(...address.line);\n }\n\n if (address.city || address.state || address.postalCode) {\n const cityStateZip = [];\n if (address.city) {\n cityStateZip.push(address.city);\n }\n if (address.state) {\n cityStateZip.push(address.state);\n }\n if (address.postalCode) {\n cityStateZip.push(address.postalCode);\n }\n builder.push(cityStateZip.join(', '));\n }\n\n if (address.use && (options?.all || options?.use)) {\n builder.push('[' + address.use + ']');\n }\n\n return builder.join(options?.lineSeparator || ', ').trim();\n}\n\nexport function formatHumanName(\n name: HumanNameR4B | HumanNameR5,\n options?: {\n all?: boolean;\n prefix?: boolean;\n suffix?: boolean;\n use?: boolean;\n }\n): string {\n const builder = [];\n\n if (name.prefix && options?.prefix !== false) {\n builder.push(...name.prefix);\n }\n\n if (name.given) {\n builder.push(...name.given);\n }\n\n if (name.family) {\n builder.push(name.family);\n }\n\n if (name.suffix && options?.suffix !== false) {\n builder.push(...name.suffix);\n }\n\n if (name.use && (options?.all || options?.use)) {\n builder.push('[' + name.use + ']');\n }\n\n return builder.join(' ').trim();\n}\n"],"names":[],"mappings":";;;AAoCA;AACA,MAAM,cAAc,GAAG,MAAM;AAC7B,SAAS,cAAc,CAAC,KAAa,EAAA;AACnC,IAAA,MAAM,IAAI,GAA4B,IAAI,UAAU,CAAC,WAAW,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC;IAChF,IAAI,MAAM,GAAG,EAAE;AAEf,IAAA,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,IAAI,CAAC,MAAM,EAAE,KAAK,IAAI,cAAc,EAAE;AAChE,QAAA,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,KAAK,GAAG,cAAc,CAAC;;AA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AI,CAAC,KAAK,CAAC;IAC7B;AAEA,IAAA,IAAI,IAAI,CAAC,MAAM,EAAE;AACf,QAAA,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC;IAC3B;IAEA,IAAI,IAAI,CAAC,MAAM,IAAI,OAAO,EAAE,MAAM,KAAK,KAAK,EAAE;QAC5C,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC;IAC9B;AAEA,IAAA,IAAI,IAAI,CAAC,GAAG,KAAK,OAAO,EAAE,GAAG,IAAI,OAAO,EAAE,GAAG,CAAC,EAAE;QAC9C,OAAO,CAAC,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;IACpC;IAEA,OAAO,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE;AACjC;;;;"}
@@ -13,6 +13,9 @@ export declare class Fhir extends SDKResource {
13
13
  search: typeof ext.search;
14
14
  create: typeof ext.create;
15
15
  get: typeof ext.get;
16
+ getAsyncJob: typeof ext.getAsyncJob;
17
+ waitForAsyncJob: typeof ext.waitForAsyncJob;
18
+ cancelAsyncJob: typeof ext.cancelAsyncJob;
16
19
  update: typeof ext.update;
17
20
  patch: typeof ext.patch;
18
21
  delete: typeof ext.delete;
@@ -1,5 +1,5 @@
1
1
  import { SDKResource } from '../../client/client.js';
2
- import { search, create, get, update, patch, delete as del, history, batch, transaction, generateFriendlyPatientId, formatAddress, formatHumanName } from './fhir-ext.js';
2
+ import { search, create, get, getAsyncJob, waitForAsyncJob, cancelAsyncJob, update, patch, delete as del, history, batch, transaction, generateFriendlyPatientId, formatAddress, formatHumanName } from './fhir-ext.js';
3
3
 
4
4
  // AUTOGENERATED -- DO NOT EDIT
5
5
  class Fhir extends SDKResource {
@@ -18,6 +18,9 @@ class Fhir extends SDKResource {
18
18
  search = search;
19
19
  create = create;
20
20
  get = get;
21
+ getAsyncJob = getAsyncJob;
22
+ waitForAsyncJob = waitForAsyncJob;
23
+ cancelAsyncJob = cancelAsyncJob;
21
24
  update = update;
22
25
  patch = patch;
23
26
  delete = del;
@@ -1 +1 @@
1
- {"version":3,"file":"fhir.js","sources":["../../../../src/resources/classes/fhir.ts"],"sourcesContent":["// AUTOGENERATED -- DO NOT EDIT\n\nimport { SDKResource } from '../../client/client';\nimport { OystehrConfig } from '../../config';\nimport * as ext from './fhir-ext';\n\nexport class Fhir extends SDKResource {\n constructor(config: OystehrConfig) {\n super(config);\n }\n #baseUrlThunk(): string {\n return this.config.services?.['fhirApiUrl'] ?? 'https://fhir-api.zapehr.com';\n }\n /**\n * Performs a FHIR search and returns the results as a Bundle resource\n * @param options FHIR resource type and FHIR search parameters\n * @param request optional OystehrClientRequest object\n * @returns FHIR Bundle resource\n */\n search = ext.search;\n create = ext.create;\n get = ext.get;\n update = ext.update;\n patch = ext.patch;\n delete = ext.delete;\n history = ext.history;\n batch = ext.batch;\n transaction = ext.transaction;\n generateFriendlyPatientId = ext.generateFriendlyPatientId;\n formatAddress = ext.formatAddress;\n formatHumanName = ext.formatHumanName;\n}\n"],"names":["ext.search","ext.create","ext.get","ext.update","ext.patch","ext.delete","ext.history","ext.batch","ext.transaction","ext.generateFriendlyPatientId","ext.formatAddress","ext.formatHumanName"],"mappings":";;;AAAA;AAMM,MAAO,IAAK,SAAQ,WAAW,CAAA;AACnC,IAAA,WAAA,CAAY,MAAqB,EAAA;QAC/B,KAAK,CAAC,MAAM,CAAC;IACf;IACA,aAAa,GAAA;QACX,OAAO,IAAI,CAAC,MAAM,CAAC,QAAQ,GAAG,YAAY,CAAC,IAAI,6BAA6B;IAC9E;AACA;;;;;AAKG;AACH,IAAA,MAAM,GAAGA,MAAU;AACnB,IAAA,MAAM,GAAGC,MAAU;AACnB,IAAA,GAAG,GAAGC,GAAO;AACb,IAAA,MAAM,GAAGC,MAAU;AACnB,IAAA,KAAK,GAAGC,KAAS;AACjB,IAAA,MAAM,GAAGC,GAAU;AACnB,IAAA,OAAO,GAAGC,OAAW;AACrB,IAAA,KAAK,GAAGC,KAAS;AACjB,IAAA,WAAW,GAAGC,WAAe;AAC7B,IAAA,yBAAyB,GAAGC,yBAA6B;AACzD,IAAA,aAAa,GAAGC,aAAiB;AACjC,IAAA,eAAe,GAAGC,eAAmB;AACtC;;;;"}
1
+ {"version":3,"file":"fhir.js","sources":["../../../../src/resources/classes/fhir.ts"],"sourcesContent":["// AUTOGENERATED -- DO NOT EDIT\n\nimport { SDKResource } from '../../client/client';\nimport { OystehrConfig } from '../../config';\nimport * as ext from './fhir-ext';\n\nexport class Fhir extends SDKResource {\n constructor(config: OystehrConfig) {\n super(config);\n }\n #baseUrlThunk(): string {\n return this.config.services?.['fhirApiUrl'] ?? 'https://fhir-api.zapehr.com';\n }\n /**\n * Performs a FHIR search and returns the results as a Bundle resource\n * @param options FHIR resource type and FHIR search parameters\n * @param request optional OystehrClientRequest object\n * @returns FHIR Bundle resource\n */\n search = ext.search;\n create = ext.create;\n get = ext.get;\n getAsyncJob = ext.getAsyncJob;\n waitForAsyncJob = ext.waitForAsyncJob;\n cancelAsyncJob = ext.cancelAsyncJob;\n update = ext.update;\n patch = ext.patch;\n delete = ext.delete;\n history = ext.history;\n batch = ext.batch;\n transaction = ext.transaction;\n generateFriendlyPatientId = ext.generateFriendlyPatientId;\n formatAddress = ext.formatAddress;\n formatHumanName = ext.formatHumanName;\n}\n"],"names":["ext.search","ext.create","ext.get","ext.getAsyncJob","ext.waitForAsyncJob","ext.cancelAsyncJob","ext.update","ext.patch","ext.delete","ext.history","ext.batch","ext.transaction","ext.generateFriendlyPatientId","ext.formatAddress","ext.formatHumanName"],"mappings":";;;AAAA;AAMM,MAAO,IAAK,SAAQ,WAAW,CAAA;AACnC,IAAA,WAAA,CAAY,MAAqB,EAAA;QAC/B,KAAK,CAAC,MAAM,CAAC;IACf;IACA,aAAa,GAAA;QACX,OAAO,IAAI,CAAC,MAAM,CAAC,QAAQ,GAAG,YAAY,CAAC,IAAI,6BAA6B;IAC9E;AACA;;;;;AAKG;AACH,IAAA,MAAM,GAAGA,MAAU;AACnB,IAAA,MAAM,GAAGC,MAAU;AACnB,IAAA,GAAG,GAAGC,GAAO;AACb,IAAA,WAAW,GAAGC,WAAe;AAC7B,IAAA,eAAe,GAAGC,eAAmB;AACrC,IAAA,cAAc,GAAGC,cAAkB;AACnC,IAAA,MAAM,GAAGC,MAAU;AACnB,IAAA,KAAK,GAAGC,KAAS;AACjB,IAAA,MAAM,GAAGC,GAAU;AACnB,IAAA,OAAO,GAAGC,OAAW;AACrB,IAAA,KAAK,GAAGC,KAAS;AACjB,IAAA,WAAW,GAAGC,WAAe;AAC7B,IAAA,yBAAyB,GAAGC,yBAA6B;AACzD,IAAA,aAAa,GAAGC,aAAiB;AACjC,IAAA,eAAe,GAAGC,eAAmB;AACtC;;;;"}