in src/router/routes/rootRoute.ts [61:140]
init() {
if (this.operations.includes('transaction') || this.operations.includes('batch')) {
this.router.post(
'/',
RouteHelper.wrapAsync(async (req: express.Request, res: express.Response) => {
if (req.body.resourceType === 'Bundle') {
if (req.body.type.toLowerCase() === 'transaction') {
const response = await this.bundleHandler.processTransaction(
req.body,
res.locals.userIdentity,
res.locals.requestContext,
res.locals.serverUrl,
res.locals.tenantId,
);
res.send(response);
} else if (req.body.type.toLowerCase() === 'batch') {
const response = await this.bundleHandler.processBatch(
req.body,
res.locals.userIdentity,
res.locals.requestContext,
res.locals.serverUrl,
res.locals.tenantId,
);
res.send(response);
} else {
throw new createError.BadRequest('This root path can only process a Bundle');
}
} else {
throw new createError.BadRequest('This root path can only process a Bundle');
}
}),
);
}
if (this.operations.includes('search-system')) {
this.router.get(
'/',
RouteHelper.wrapAsync(async (req: express.Request, res: express.Response) => {
const searchParamQuery = req.query;
const response = await this.rootHandler.globalSearch(
searchParamQuery,
res.locals.userIdentity,
res.locals.requestContext,
res.locals.serverUrl,
res.locals.tenantId,
);
const updatedReadResponse = await this.authService.authorizeAndFilterReadResponse({
operation: 'search-system',
userIdentity: res.locals.userIdentity,
requestContext: res.locals.requestContext,
readResponse: response,
fhirServiceBaseUrl: res.locals.serverUrl,
});
res.send(updatedReadResponse);
}),
);
}
if (this.operations.includes('history-system')) {
this.router.get(
'/_history',
RouteHelper.wrapAsync(async (req: express.Request, res: express.Response) => {
const searchParamQuery = req.query;
const response = await this.rootHandler.globalHistory(
searchParamQuery,
res.locals.userIdentity,
res.locals.requestContext,
res.locals.serverUrl,
res.locals.tenantId,
);
const updatedReadResponse = await this.authService.authorizeAndFilterReadResponse({
operation: 'history-system',
userIdentity: res.locals.userIdentity,
requestContext: res.locals.requestContext,
readResponse: response,
fhirServiceBaseUrl: res.locals.serverUrl,
});
res.send(updatedReadResponse);
}),
);
}
}