Skip to content

Commit 97add34

Browse files
authored
add include project for download (#46)
* add include project for download * incorporate review comments
1 parent bcfe7f9 commit 97add34

File tree

17 files changed

+455
-52
lines changed

17 files changed

+455
-52
lines changed

package-lock.json

Lines changed: 50 additions & 35 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "kf-api-portal-reports",
33
"version": "1.2.3",
4-
"description": "The Kids First Download Clinical Data API offers an endpoint to generate a report of clinical data based on a query built using the Kids First Portal.",
4+
"description": "The Download Clinical Data API offers an endpoint to generate a report of clinical data based on a query built using the:",
55
"main": "index.js",
66
"scripts": {
77
"start": "node ./dist/index.js",
@@ -44,7 +44,7 @@
4444
},
4545
"dependencies": {
4646
"@elastic/elasticsearch": "^7.4.0",
47-
"@kfarranger/middleware": "1.5.2",
47+
"@arranger/middleware": "2.16.1",
4848
"cors": "^2.8.5",
4949
"dotenv": "^8.1.0",
5050
"excel4node": "^1.7.2",

src/env.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ export const ES_HOST = process.env.ES_HOST || 'kf-arranger-es-prd.kids-first.io:
1010
// ElasticSearch queries parameters
1111
export const ES_PAGESIZE: number = Number(process.env.ES_PAGESIZE) || 1000;
1212

13+
// Project
14+
export const PROJECT: string = process.env.PROJECT || 'kids-first';
15+
1316
// Keycloak configs
1417
export const KEYCLOAK_URL = process.env.KEYCLOAK_URL || 'https://kf-keycloak-qa.kf-strides.org/auth';
1518
export const KEYCLOAK_REALM = process.env.KEYCLOAK_REALM || 'kidsfirstdrc';
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import { QueryConfig, ReportConfig, SheetConfig } from '../types';
2+
3+
const biospecimens: SheetConfig = {
4+
sheetName: 'Biospecimens',
5+
root: 'biospecimens',
6+
columns: [
7+
{ field: 'fhir_id' },
8+
{ field: 'external_id' },
9+
{ field: 'files.biospecimens.biospecimen_id', header: 'Biospecimens Biospecimens Id' },
10+
{
11+
field: 'files.biospecimens.age_at_biospecimen_collection',
12+
header: 'Biospecimens Age At Biospecimen Collection',
13+
},
14+
{ field: 'files.biospecimens.bio_repository', header: 'Biospecimens Bio Repository' },
15+
{ field: 'files.biospecimens.biospecimen_type', header: 'Biospecimens Biospecimen Type' },
16+
{ field: 'files.biospecimens.derived_sample_id', header: 'Biospecimens Derived Sample Id' },
17+
{ field: 'files.biospecimens.derived_sample_type', header: 'Biospecimens Derived Sample Type' },
18+
{ field: 'files.biospecimens.ncit_id_tissue_type', header: 'Biospecimens NCIT Id Tissue Type' },
19+
{ field: 'files.biospecimens.sample_id', header: 'Biospecimens Sample Id' },
20+
{ field: 'files.biospecimens.sample_type', header: 'Biospecimens Sample Type' },
21+
],
22+
sort: [
23+
{
24+
'files.biospecimens.biospecimen_id': {
25+
order: 'asc',
26+
},
27+
},
28+
{
29+
fhir_id: {
30+
order: 'asc',
31+
},
32+
},
33+
],
34+
};
35+
36+
const queryConfigs: QueryConfig = {
37+
indexName: 'participant',
38+
alias: 'participant_centric',
39+
};
40+
41+
const sheetConfigs: SheetConfig[] = [biospecimens];
42+
43+
const reportConfig: ReportConfig = { queryConfigs, sheetConfigs };
44+
45+
export default reportConfig;

src/reports/biospecimen-data/index.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
import { Request, Response } from 'express';
22
import { Client } from '@elastic/elasticsearch';
33
import generateReport from '../generateReport';
4-
import reportConfig from './config';
4+
import configKf from './configKf';
5+
import configInclude from './configInclude';
6+
import { PROJECT } from '../../env';
57
import { normalizeConfigs } from '../../utils/configUtils';
68
import ExtendedReportConfigs from '../../utils/extendedReportConfigs';
79
import { reportGenerationErrorHandler } from '../../errors';
10+
import { ProjectType } from '../types';
811

912
const clinicalDataReport = (esHost: string) => async (req: Request, res: Response) => {
1013
console.time('biospecimen-data');
@@ -13,6 +16,8 @@ const clinicalDataReport = (esHost: string) => async (req: Request, res: Respons
1316
const userId = req['kauth']?.grant?.access_token?.content?.sub;
1417
const accessToken = req.headers.authorization;
1518

19+
const reportConfig = PROJECT.toLowerCase().trim() === ProjectType.kidsFirst ? configKf : configInclude;
20+
1621
let es = null;
1722
try {
1823
// prepare the ES client

0 commit comments

Comments
 (0)