in src/router/bundle/bundleGenerator.ts [88:131]
static generateTransactionBundle(baseUrl: string, bundleEntryResponses: BatchReadWriteResponse[]) {
const id = uuidv4();
const response = {
resourceType: 'Bundle',
id,
type: 'transaction-response',
link: [
{
relation: 'self',
url: baseUrl,
},
],
entry: [],
};
const entries: any = [];
bundleEntryResponses.forEach((bundleEntryResponse) => {
let status = '200 OK';
if (bundleEntryResponse.operation === 'create') {
status = '201 Created';
} else if (
['read', 'vread'].includes(bundleEntryResponse.operation) &&
isEmpty(bundleEntryResponse.resource)
) {
status = '403 Forbidden';
}
const entry: any = {
response: {
status,
location: `${bundleEntryResponse.resourceType}/${bundleEntryResponse.id}`,
etag: bundleEntryResponse.vid,
lastModified: bundleEntryResponse.lastModified,
},
};
if (bundleEntryResponse.operation === 'read') {
entry.resource = bundleEntryResponse.resource;
}
entries.push(entry);
});
response.entry = entries;
return response;
}