Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

create transaction response bundle #115

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions service/src/services/LibraryService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ import {
createLibraryPackageBundle,
createPaginationLinks,
createSearchsetBundle,
createSummarySearchsetBundle
createSummarySearchsetBundle,
createTransactionResponseBundle
} from '../util/bundleUtils';
import { BadRequestError, ResourceNotFoundError } from '../util/errorUtils';
import { getMongoQueryFromRequest } from '../util/queryUtils';
Expand Down Expand Up @@ -231,7 +232,7 @@ export class LibraryService implements Service<CRMIShareableLibrary> {
const newDeletes = await batchDelete([library, ...children], archiveOrWithdraw);

// we want to return a Bundle containing the deleted artifacts
return createBatchResponseBundle(newDeletes);
return createTransactionResponseBundle(newDeletes);
}

/**
Expand Down
5 changes: 3 additions & 2 deletions service/src/services/MeasureService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ import {
createPaginationLinks,
createMeasurePackageBundle,
createSearchsetBundle,
createSummarySearchsetBundle
createSummarySearchsetBundle,
createTransactionResponseBundle
} from '../util/bundleUtils';
import { BadRequestError, ResourceNotFoundError } from '../util/errorUtils';
import { getMongoQueryFromRequest } from '../util/queryUtils';
Expand Down Expand Up @@ -235,7 +236,7 @@ export class MeasureService implements Service<CRMIShareableMeasure> {
const newDeletes = await batchDelete([measure, ...children], archiveOrWithdraw);

// we want to return a Bundle containing the deleted artifacts
return createBatchResponseBundle(newDeletes);
return createTransactionResponseBundle(newDeletes);
}

/**
Expand Down
11 changes: 11 additions & 0 deletions service/src/util/bundleUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,17 @@ export function createBatchResponseBundle<T extends FhirArtifact>(entries: T[]):
};
}

export function createTransactionResponseBundle<T extends FhirArtifact>(entries: T[]): fhir4.Bundle<T> {
return {
resourceType: 'Bundle',
meta: { lastUpdated: new Date().toISOString() },
id: v4(),
type: 'transaction-response',
total: entries.length,
entry: entries.map(e => ({ resource: e }))
};
}

/**
*
* Takes in a number of FHIR resources and creates a FHIR searchset Bundle without entries
Expand Down
Loading