@oystehr/sdk 4.3.9 → 4.3.10
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.
- package/dist/cjs/index.min.cjs +1 -1
- package/dist/cjs/index.min.cjs.map +1 -1
- package/dist/cjs/resources/classes/fhir-ext.cjs +169 -0
- package/dist/cjs/resources/classes/fhir-ext.cjs.map +1 -1
- package/dist/cjs/resources/classes/fhir-ext.d.ts +48 -1
- package/dist/cjs/resources/classes/fhir.cjs +14 -3
- package/dist/cjs/resources/classes/fhir.cjs.map +1 -1
- package/dist/cjs/resources/classes/fhir.d.ts +14 -3
- package/dist/cjs/resources/types/FaxSendParams.d.ts +1 -1
- package/dist/cjs/resources/types/ZambdaCreateParams.d.ts +1 -1
- package/dist/cjs/resources/types/ZambdaUpdateParams.d.ts +1 -1
- package/dist/cjs/resources/types/fhir.d.ts +7 -0
- package/dist/esm/index.min.js +1 -1
- package/dist/esm/index.min.js.map +1 -1
- package/dist/esm/resources/classes/fhir-ext.d.ts +48 -1
- package/dist/esm/resources/classes/fhir-ext.js +167 -1
- package/dist/esm/resources/classes/fhir-ext.js.map +1 -1
- package/dist/esm/resources/classes/fhir.d.ts +14 -3
- package/dist/esm/resources/classes/fhir.js +15 -4
- package/dist/esm/resources/classes/fhir.js.map +1 -1
- package/dist/esm/resources/types/FaxSendParams.d.ts +1 -1
- package/dist/esm/resources/types/ZambdaCreateParams.d.ts +1 -1
- package/dist/esm/resources/types/ZambdaUpdateParams.d.ts +1 -1
- package/dist/esm/resources/types/fhir.d.ts +7 -0
- package/package.json +1 -1
- package/src/resources/classes/fhir-ext.ts +205 -0
- package/src/resources/classes/fhir.ts +14 -3
- package/src/resources/types/FaxSendParams.ts +1 -1
- package/src/resources/types/ZambdaCreateParams.ts +1 -1
- package/src/resources/types/ZambdaUpdateParams.ts +1 -1
- package/src/resources/types/fhir.ts +9 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SDKResource } from '../../client/client.js';
|
|
2
|
-
import { search, create, get,
|
|
2
|
+
import { search, searchAndGetAllPages, create, get, update, patch, delete as del, getAsyncJob, waitForAsyncJob, waitForAsyncBulkOutput, waitForAsyncBulkBundle, cancelAsyncJob, history, batch, transaction, generateFriendlyPatientId, formatAddress, formatHumanName } from './fhir-ext.js';
|
|
3
3
|
|
|
4
4
|
// AUTOGENERATED -- DO NOT EDIT
|
|
5
5
|
class Fhir extends SDKResource {
|
|
@@ -16,14 +16,25 @@ class Fhir extends SDKResource {
|
|
|
16
16
|
* @returns FHIR Bundle resource
|
|
17
17
|
*/
|
|
18
18
|
search = search;
|
|
19
|
+
/**
|
|
20
|
+
* Performs an iterative FHIR search over initial request and following "next" urls,
|
|
21
|
+
* collecting all pages into a single Bundle.
|
|
22
|
+
* @param params FHIR search parameters plus optional pageSize that will overwrite _count in params
|
|
23
|
+
* @param request optional OystehrClientRequest object
|
|
24
|
+
* @returns FHIR Bundle resource that contains all entries across all pages. Bundle-level metadata
|
|
25
|
+
* (id, meta, total, etc.) is taken from the first page.
|
|
26
|
+
*/
|
|
27
|
+
searchAndGetAllPages = searchAndGetAllPages;
|
|
19
28
|
create = create;
|
|
20
29
|
get = get;
|
|
21
|
-
getAsyncJob = getAsyncJob;
|
|
22
|
-
waitForAsyncJob = waitForAsyncJob;
|
|
23
|
-
cancelAsyncJob = cancelAsyncJob;
|
|
24
30
|
update = update;
|
|
25
31
|
patch = patch;
|
|
26
32
|
delete = del;
|
|
33
|
+
getAsyncJob = getAsyncJob;
|
|
34
|
+
waitForAsyncJob = waitForAsyncJob;
|
|
35
|
+
waitForAsyncBulkOutput = waitForAsyncBulkOutput;
|
|
36
|
+
waitForAsyncBulkBundle = waitForAsyncBulkBundle;
|
|
37
|
+
cancelAsyncJob = cancelAsyncJob;
|
|
27
38
|
history = history;
|
|
28
39
|
batch = batch;
|
|
29
40
|
transaction = transaction;
|
|
@@ -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
|
|
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 /**\n * Performs an iterative FHIR search over initial request and following \"next\" urls,\n * collecting all pages into a single Bundle.\n * @param params FHIR search parameters plus optional pageSize that will overwrite _count in params\n * @param request optional OystehrClientRequest object\n * @returns FHIR Bundle resource that contains all entries across all pages. Bundle-level metadata\n * (id, meta, total, etc.) is taken from the first page.\n */\n searchAndGetAllPages = ext.searchAndGetAllPages;\n create = ext.create;\n get = ext.get;\n update = ext.update;\n patch = ext.patch;\n delete = ext.delete;\n getAsyncJob = ext.getAsyncJob;\n waitForAsyncJob = ext.waitForAsyncJob;\n waitForAsyncBulkOutput = ext.waitForAsyncBulkOutput;\n waitForAsyncBulkBundle = ext.waitForAsyncBulkBundle;\n cancelAsyncJob = ext.cancelAsyncJob;\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.searchAndGetAllPages","ext.create","ext.get","ext.update","ext.patch","ext.delete","ext.getAsyncJob","ext.waitForAsyncJob","ext.waitForAsyncBulkOutput","ext.waitForAsyncBulkBundle","ext.cancelAsyncJob","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;;;;;;;AAOG;AACH,IAAA,oBAAoB,GAAGC,oBAAwB;AAC/C,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,WAAW,GAAGC,WAAe;AAC7B,IAAA,eAAe,GAAGC,eAAmB;AACrC,IAAA,sBAAsB,GAAGC,sBAA0B;AACnD,IAAA,sBAAsB,GAAGC,sBAA0B;AACnD,IAAA,cAAc,GAAGC,cAAkB;AACnC,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;;;;"}
|
|
@@ -12,7 +12,7 @@ export interface ZambdaCreateParams {
|
|
|
12
12
|
/**
|
|
13
13
|
* The runtime to use for the Zambda Function.
|
|
14
14
|
*/
|
|
15
|
-
runtime: '
|
|
15
|
+
runtime: 'nodejs22.x' | 'nodejs24.x' | 'python3.13' | 'python3.12' | 'java21' | 'dotnet8' | 'ruby3.3';
|
|
16
16
|
/**
|
|
17
17
|
* The amount of memory in MB to allocate to the Zambda Function. If not specified, a system default (1024MB) will be used. Min: 128MB, Max: 10240MB.
|
|
18
18
|
*/
|
|
@@ -12,7 +12,7 @@ export interface ZambdaUpdateParams {
|
|
|
12
12
|
/**
|
|
13
13
|
* The runtime to use for the Zambda Function.
|
|
14
14
|
*/
|
|
15
|
-
runtime?: '
|
|
15
|
+
runtime?: 'nodejs22.x' | 'nodejs24.x' | 'python3.13' | 'python3.12' | 'java21' | 'dotnet8' | 'ruby3.3';
|
|
16
16
|
/**
|
|
17
17
|
* The amount of memory in MB to allocate to the Zambda Function. If not specified, a system default (1024MB) will be used. Min: 128MB, Max: 10240MB.
|
|
18
18
|
*/
|
|
@@ -167,6 +167,13 @@ export interface FhirAsyncJobCompletedBulk {
|
|
|
167
167
|
mode: 'bulk';
|
|
168
168
|
manifest: FhirAsyncBulkManifest;
|
|
169
169
|
}
|
|
170
|
+
export interface FhirAsyncBulkOutputFileResult<T extends FhirResource = FhirResource> extends FhirAsyncBulkOutputFile {
|
|
171
|
+
resources: T[];
|
|
172
|
+
}
|
|
173
|
+
export interface FhirAsyncBulkOutputResult<T extends FhirResource = FhirResource> {
|
|
174
|
+
manifest: FhirAsyncBulkManifest;
|
|
175
|
+
output: FhirAsyncBulkOutputFileResult<T>[];
|
|
176
|
+
}
|
|
170
177
|
export interface FhirAsyncJobExpired {
|
|
171
178
|
status: 410;
|
|
172
179
|
}
|
package/package.json
CHANGED
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
Bundle,
|
|
10
10
|
BundleEntry,
|
|
11
11
|
Coding,
|
|
12
|
+
FhirAsyncBulkOutputResult,
|
|
12
13
|
FhirAsyncJobHandle,
|
|
13
14
|
FhirAsyncJobStatus,
|
|
14
15
|
FhirAsyncWaitOptions,
|
|
@@ -329,6 +330,58 @@ export async function search<T extends FhirResource>(
|
|
|
329
330
|
return bundle;
|
|
330
331
|
}
|
|
331
332
|
|
|
333
|
+
/**
|
|
334
|
+
* Performs an iterative FHIR search over initial request and following "next" urls,
|
|
335
|
+
* collecting all pages into a single Bundle.
|
|
336
|
+
*
|
|
337
|
+
* @param params FHIR search parameters plus optional pageSize that will overwrite _count in params
|
|
338
|
+
* @param request optional OystehrClientRequest object
|
|
339
|
+
* @returns FHIR Bundle resource that contains all entries across all pages. Bundle-level metadata
|
|
340
|
+
* (id, meta, total, etc.) is taken from the first page.
|
|
341
|
+
*/
|
|
342
|
+
export async function searchAndGetAllPages<T extends FhirResource>(
|
|
343
|
+
this: SDKResource,
|
|
344
|
+
params: FhirSearchParams<T> & { pageSize?: number },
|
|
345
|
+
request?: OystehrClientRequest & { mode?: 'sync' | undefined }
|
|
346
|
+
): Promise<Bundle<T>> {
|
|
347
|
+
const { pageSize, ...searchParams } = params;
|
|
348
|
+
|
|
349
|
+
let firstPageParams: FhirSearchParams<T> = searchParams;
|
|
350
|
+
if (pageSize) {
|
|
351
|
+
const baseParams = (searchParams.params ?? []).filter((p) => p.name !== '_count') ?? [];
|
|
352
|
+
firstPageParams = { ...searchParams, params: [...baseParams, { name: '_count', value: pageSize }] };
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
const allEntries: Array<BundleEntry<T>> = [];
|
|
356
|
+
|
|
357
|
+
const typedSearch = search<T>;
|
|
358
|
+
// search returns Bundle, and fhirRequest in the while block returns FhirBundle
|
|
359
|
+
let currentBundle: Bundle<T> | FhirBundle<T> = await typedSearch.call(this, firstPageParams, request);
|
|
360
|
+
const firstBundle = { ...currentBundle, link: currentBundle.link?.filter((link) => link.relation !== 'next') };
|
|
361
|
+
|
|
362
|
+
// eslint-disable-next-line no-constant-condition
|
|
363
|
+
while (true) {
|
|
364
|
+
const entries = currentBundle.entry as Array<BundleEntry<T>> | undefined;
|
|
365
|
+
if (entries) {
|
|
366
|
+
allEntries.push(...entries);
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
const nextLink: string | undefined = currentBundle.link?.find((link) => link.relation === 'next')?.url;
|
|
370
|
+
if (!nextLink) {
|
|
371
|
+
break;
|
|
372
|
+
}
|
|
373
|
+
currentBundle = await this.fhirRequest<FhirBundle<T>>(nextLink, 'GET')({}, request);
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
return {
|
|
377
|
+
...firstBundle,
|
|
378
|
+
entry: allEntries.length ? allEntries : undefined,
|
|
379
|
+
unbundle: function (this: { entry?: Array<BundleEntry<T>> }) {
|
|
380
|
+
return this.entry?.map((e) => e.resource).filter((r): r is T => r !== undefined) ?? [];
|
|
381
|
+
},
|
|
382
|
+
};
|
|
383
|
+
}
|
|
384
|
+
|
|
332
385
|
export async function create<T extends FhirResource>(
|
|
333
386
|
this: SDKResource,
|
|
334
387
|
params: FhirCreateParams<T>,
|
|
@@ -510,6 +563,13 @@ function getRetryDelayMs(retryAfter: string | undefined, fallbackMs: number): nu
|
|
|
510
563
|
return fallbackMs;
|
|
511
564
|
}
|
|
512
565
|
|
|
566
|
+
/**
|
|
567
|
+
* Fetches the status of an async job. If the job is still in progress, returns an object with status 202. If the job is completed, returns the job result with status 200. If the job has failed, returns an object with status 500 and an OperationOutcome resource describing the failure. If the job has expired, returns an object with status 410.
|
|
568
|
+
* @param this The SDKResource context (this is an extension method and should be called with the SDKResource instance as the context, e.g. `sdkResource.getAsyncJob(jobId)`)
|
|
569
|
+
* @param jobId The ID of the async job to fetch
|
|
570
|
+
* @param request Optional OystehrClientRequest for authentication and headers
|
|
571
|
+
* @returns A Promise that resolves to the FhirAsyncJobStatus
|
|
572
|
+
*/
|
|
513
573
|
export async function getAsyncJob<T extends FhirResource>(
|
|
514
574
|
this: SDKResource,
|
|
515
575
|
jobId: string,
|
|
@@ -518,6 +578,14 @@ export async function getAsyncJob<T extends FhirResource>(
|
|
|
518
578
|
return await this.fetchAsyncJobStatus<T>(jobId, request);
|
|
519
579
|
}
|
|
520
580
|
|
|
581
|
+
/**
|
|
582
|
+
* Waits for an async job to complete by polling its status until it reaches a terminal state (success, failure, or expiration) or the specified timeout is reached. Returns the final job status. Throws if the job fails, expires, or does not complete within the timeout.
|
|
583
|
+
* @param this The SDKResource context (this is an extension method and should be called with the SDKResource instance as the context, e.g. `sdkResource.waitForAsyncJob(jobId)`)
|
|
584
|
+
* @param jobId The ID of the async job to wait for
|
|
585
|
+
* @param options Optional FhirAsyncWaitOptions to configure polling behavior
|
|
586
|
+
* @param request Optional OystehrClientRequest for authentication and headers
|
|
587
|
+
* @returns A Promise that resolves to the final FhirAsyncJobStatus
|
|
588
|
+
*/
|
|
521
589
|
export async function waitForAsyncJob<T extends FhirResource>(
|
|
522
590
|
this: SDKResource,
|
|
523
591
|
jobId: string,
|
|
@@ -548,6 +616,143 @@ export async function waitForAsyncJob<T extends FhirResource>(
|
|
|
548
616
|
});
|
|
549
617
|
}
|
|
550
618
|
|
|
619
|
+
function parseNdjsonResources<T extends FhirResource>(ndjson: string, sourceUrl: string): T[] {
|
|
620
|
+
const resources: T[] = [];
|
|
621
|
+
const lines = ndjson.split('\n');
|
|
622
|
+
for (let index = 0; index < lines.length; index++) {
|
|
623
|
+
const line = lines[index].trim();
|
|
624
|
+
if (line.length === 0) {
|
|
625
|
+
continue;
|
|
626
|
+
}
|
|
627
|
+
try {
|
|
628
|
+
resources.push(JSON.parse(line) as T);
|
|
629
|
+
} catch (error) {
|
|
630
|
+
throw new OystehrSdkError({
|
|
631
|
+
message: `Failed to parse NDJSON line ${index + 1} from ${sourceUrl}`,
|
|
632
|
+
code: 500,
|
|
633
|
+
cause: error,
|
|
634
|
+
});
|
|
635
|
+
}
|
|
636
|
+
}
|
|
637
|
+
return resources;
|
|
638
|
+
}
|
|
639
|
+
|
|
640
|
+
/**
|
|
641
|
+
* Waits for an async job to complete and retrieves the bulk output manifest and files. Throws if the job fails, expires, or does not complete within the specified timeout.
|
|
642
|
+
* @param this The SDKResource context (this is an extension method and should be called with the SDKResource instance as the context, e.g. `sdkResource.waitForAsyncBulkOutput(jobId)`)
|
|
643
|
+
* @param jobId The ID of the async job to wait for
|
|
644
|
+
* @param options Optional FhirAsyncWaitOptions to configure polling behavior
|
|
645
|
+
* @param request Optional OystehrClientRequest for authentication and headers
|
|
646
|
+
* @returns A Promise that resolves to a FhirAsyncBulkOutputResult containing the bulk output manifest and files
|
|
647
|
+
*/
|
|
648
|
+
export async function waitForAsyncBulkOutput<T extends FhirResource>(
|
|
649
|
+
this: SDKResource,
|
|
650
|
+
jobId: string,
|
|
651
|
+
options?: FhirAsyncWaitOptions,
|
|
652
|
+
request?: OystehrClientRequest
|
|
653
|
+
): Promise<FhirAsyncBulkOutputResult<T>> {
|
|
654
|
+
const status = await waitForAsyncJob.call(this, jobId, options, request);
|
|
655
|
+
|
|
656
|
+
if (status.status === 404) {
|
|
657
|
+
throw new OystehrSdkError({
|
|
658
|
+
message: `Async job ${jobId} not found`,
|
|
659
|
+
code: 404,
|
|
660
|
+
});
|
|
661
|
+
}
|
|
662
|
+
|
|
663
|
+
if (status.status === 410) {
|
|
664
|
+
throw new OystehrSdkError({
|
|
665
|
+
message: `Async job ${jobId} expired`,
|
|
666
|
+
code: 410,
|
|
667
|
+
});
|
|
668
|
+
}
|
|
669
|
+
|
|
670
|
+
if (status.status !== 200 || !('mode' in status) || status.mode !== 'bulk') {
|
|
671
|
+
throw new OystehrSdkError({
|
|
672
|
+
message: `Async job ${jobId} did not complete in bulk mode`,
|
|
673
|
+
code: status.status,
|
|
674
|
+
});
|
|
675
|
+
}
|
|
676
|
+
|
|
677
|
+
const accessToken = request?.accessToken ?? this.config.accessToken;
|
|
678
|
+
const projectId = request?.projectId ?? this.config.projectId;
|
|
679
|
+
if (status.manifest.requiresAccessToken && !accessToken) {
|
|
680
|
+
throw new OystehrSdkError({
|
|
681
|
+
message: `Bulk output for async job ${jobId} requires an access token`,
|
|
682
|
+
code: 401,
|
|
683
|
+
});
|
|
684
|
+
}
|
|
685
|
+
|
|
686
|
+
const fetchImpl = this.config.fetch ?? fetch;
|
|
687
|
+
const headers: Record<string, string> = {};
|
|
688
|
+
if (projectId) {
|
|
689
|
+
headers['x-zapehr-project-id'] = projectId;
|
|
690
|
+
headers['x-oystehr-project-id'] = projectId;
|
|
691
|
+
}
|
|
692
|
+
if (status.manifest.requiresAccessToken && accessToken) {
|
|
693
|
+
headers.Authorization = `Bearer ${accessToken}`;
|
|
694
|
+
}
|
|
695
|
+
const requestHeaders = Object.keys(headers).length > 0 ? headers : undefined;
|
|
696
|
+
|
|
697
|
+
const output = await Promise.all(
|
|
698
|
+
status.manifest.output.map(async (file) => {
|
|
699
|
+
const response = await fetchImpl(
|
|
700
|
+
new Request(file.url, {
|
|
701
|
+
method: 'GET',
|
|
702
|
+
headers: requestHeaders,
|
|
703
|
+
})
|
|
704
|
+
);
|
|
705
|
+
|
|
706
|
+
if (!response.ok) {
|
|
707
|
+
throw new OystehrSdkError({
|
|
708
|
+
message: `Failed to download bulk output (${file.type}): HTTP ${response.status}`,
|
|
709
|
+
code: response.status,
|
|
710
|
+
});
|
|
711
|
+
}
|
|
712
|
+
|
|
713
|
+
const ndjson = await response.text();
|
|
714
|
+
return {
|
|
715
|
+
...file,
|
|
716
|
+
resources: parseNdjsonResources<T>(ndjson, file.url),
|
|
717
|
+
};
|
|
718
|
+
})
|
|
719
|
+
);
|
|
720
|
+
|
|
721
|
+
return {
|
|
722
|
+
manifest: status.manifest,
|
|
723
|
+
output,
|
|
724
|
+
};
|
|
725
|
+
}
|
|
726
|
+
|
|
727
|
+
/**
|
|
728
|
+
* Wrapper around waitForAsyncBulkOutput that transforms the retrieved bulk output files into a single Bundle resource containing all the output resources as entries. This is a convenience method for use cases where you want to work with the bulk output as a Bundle, but it may not be efficient for large outputs due to the overhead of downloading and parsing all files and constructing the Bundle in memory.
|
|
729
|
+
* Can be slow due to downloading and parsing potentially large NDJSON files, so use only if you need the full output as a Bundle resource. For more efficient processing of large bulk outputs, use waitForAsyncBulkOutput directly.
|
|
730
|
+
* @param jobId the ID of the async job to wait for
|
|
731
|
+
* @param options optional FhirAsyncWaitOptions to configure polling behavior
|
|
732
|
+
* @param request optional OystehrClientRequest for authentication and headers
|
|
733
|
+
* @returns a Promise that resolves to a Bundle containing all resources from the bulk output
|
|
734
|
+
*/
|
|
735
|
+
export async function waitForAsyncBulkBundle<T extends FhirResource>(
|
|
736
|
+
this: SDKResource,
|
|
737
|
+
jobId: string,
|
|
738
|
+
options?: FhirAsyncWaitOptions,
|
|
739
|
+
request?: OystehrClientRequest
|
|
740
|
+
): Promise<Bundle<T>> {
|
|
741
|
+
const bulkOutput = await waitForAsyncBulkOutput.call(this, jobId, options, request);
|
|
742
|
+
const resources = bulkOutput.output.flatMap((file) => file.resources);
|
|
743
|
+
|
|
744
|
+
const bundle = {
|
|
745
|
+
resourceType: 'Bundle',
|
|
746
|
+
type: 'collection',
|
|
747
|
+
entry: resources.map((resource) => ({ resource } as BundleEntry<T>)),
|
|
748
|
+
unbundle: function (this: { entry?: Array<BundleEntry<T>> | undefined }) {
|
|
749
|
+
return this.entry?.map((entry) => entry.resource).filter((value): value is T => value !== undefined) ?? [];
|
|
750
|
+
},
|
|
751
|
+
} as unknown as Bundle<T>;
|
|
752
|
+
|
|
753
|
+
return bundle;
|
|
754
|
+
}
|
|
755
|
+
|
|
551
756
|
export async function cancelAsyncJob(this: SDKResource, jobId: string, request?: OystehrClientRequest): Promise<void> {
|
|
552
757
|
await this.fhirRequest(`/async-job/${jobId}`, 'DELETE')({}, request);
|
|
553
758
|
}
|
|
@@ -18,14 +18,25 @@ export class Fhir extends SDKResource {
|
|
|
18
18
|
* @returns FHIR Bundle resource
|
|
19
19
|
*/
|
|
20
20
|
search = ext.search;
|
|
21
|
+
/**
|
|
22
|
+
* Performs an iterative FHIR search over initial request and following "next" urls,
|
|
23
|
+
* collecting all pages into a single Bundle.
|
|
24
|
+
* @param params FHIR search parameters plus optional pageSize that will overwrite _count in params
|
|
25
|
+
* @param request optional OystehrClientRequest object
|
|
26
|
+
* @returns FHIR Bundle resource that contains all entries across all pages. Bundle-level metadata
|
|
27
|
+
* (id, meta, total, etc.) is taken from the first page.
|
|
28
|
+
*/
|
|
29
|
+
searchAndGetAllPages = ext.searchAndGetAllPages;
|
|
21
30
|
create = ext.create;
|
|
22
31
|
get = ext.get;
|
|
23
|
-
getAsyncJob = ext.getAsyncJob;
|
|
24
|
-
waitForAsyncJob = ext.waitForAsyncJob;
|
|
25
|
-
cancelAsyncJob = ext.cancelAsyncJob;
|
|
26
32
|
update = ext.update;
|
|
27
33
|
patch = ext.patch;
|
|
28
34
|
delete = ext.delete;
|
|
35
|
+
getAsyncJob = ext.getAsyncJob;
|
|
36
|
+
waitForAsyncJob = ext.waitForAsyncJob;
|
|
37
|
+
waitForAsyncBulkOutput = ext.waitForAsyncBulkOutput;
|
|
38
|
+
waitForAsyncBulkBundle = ext.waitForAsyncBulkBundle;
|
|
39
|
+
cancelAsyncJob = ext.cancelAsyncJob;
|
|
29
40
|
history = ext.history;
|
|
30
41
|
batch = ext.batch;
|
|
31
42
|
transaction = ext.transaction;
|
|
@@ -15,7 +15,7 @@ export interface ZambdaCreateParams {
|
|
|
15
15
|
/**
|
|
16
16
|
* The runtime to use for the Zambda Function.
|
|
17
17
|
*/
|
|
18
|
-
runtime: '
|
|
18
|
+
runtime: 'nodejs22.x' | 'nodejs24.x' | 'python3.13' | 'python3.12' | 'java21' | 'dotnet8' | 'ruby3.3';
|
|
19
19
|
/**
|
|
20
20
|
* The amount of memory in MB to allocate to the Zambda Function. If not specified, a system default (1024MB) will be used. Min: 128MB, Max: 10240MB.
|
|
21
21
|
*/
|
|
@@ -15,7 +15,7 @@ export interface ZambdaUpdateParams {
|
|
|
15
15
|
/**
|
|
16
16
|
* The runtime to use for the Zambda Function.
|
|
17
17
|
*/
|
|
18
|
-
runtime?: '
|
|
18
|
+
runtime?: 'nodejs22.x' | 'nodejs24.x' | 'python3.13' | 'python3.12' | 'java21' | 'dotnet8' | 'ruby3.3';
|
|
19
19
|
/**
|
|
20
20
|
* The amount of memory in MB to allocate to the Zambda Function. If not specified, a system default (1024MB) will be used. Min: 128MB, Max: 10240MB.
|
|
21
21
|
*/
|
|
@@ -227,6 +227,15 @@ export interface FhirAsyncJobCompletedBulk {
|
|
|
227
227
|
manifest: FhirAsyncBulkManifest;
|
|
228
228
|
}
|
|
229
229
|
|
|
230
|
+
export interface FhirAsyncBulkOutputFileResult<T extends FhirResource = FhirResource> extends FhirAsyncBulkOutputFile {
|
|
231
|
+
resources: T[];
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
export interface FhirAsyncBulkOutputResult<T extends FhirResource = FhirResource> {
|
|
235
|
+
manifest: FhirAsyncBulkManifest;
|
|
236
|
+
output: FhirAsyncBulkOutputFileResult<T>[];
|
|
237
|
+
}
|
|
238
|
+
|
|
230
239
|
export interface FhirAsyncJobExpired {
|
|
231
240
|
status: 410;
|
|
232
241
|
}
|