Skip to content

Commit

Permalink
add include project for download (#46)
Browse files Browse the repository at this point in the history
* add include project for download

* incorporate review comments
  • Loading branch information
adipaul1981 authored Jan 31, 2022
1 parent bcfe7f9 commit 97add34
Show file tree
Hide file tree
Showing 17 changed files with 455 additions and 52 deletions.
85 changes: 50 additions & 35 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "kf-api-portal-reports",
"version": "1.2.3",
"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.",
"description": "The Download Clinical Data API offers an endpoint to generate a report of clinical data based on a query built using the:",
"main": "index.js",
"scripts": {
"start": "node ./dist/index.js",
Expand Down Expand Up @@ -44,7 +44,7 @@
},
"dependencies": {
"@elastic/elasticsearch": "^7.4.0",
"@kfarranger/middleware": "1.5.2",
"@arranger/middleware": "2.16.1",
"cors": "^2.8.5",
"dotenv": "^8.1.0",
"excel4node": "^1.7.2",
Expand Down
3 changes: 3 additions & 0 deletions src/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ export const ES_HOST = process.env.ES_HOST || 'kf-arranger-es-prd.kids-first.io:
// ElasticSearch queries parameters
export const ES_PAGESIZE: number = Number(process.env.ES_PAGESIZE) || 1000;

// Project
export const PROJECT: string = process.env.PROJECT || 'kids-first';

// Keycloak configs
export const KEYCLOAK_URL = process.env.KEYCLOAK_URL || 'https://kf-keycloak-qa.kf-strides.org/auth';
export const KEYCLOAK_REALM = process.env.KEYCLOAK_REALM || 'kidsfirstdrc';
Expand Down
45 changes: 45 additions & 0 deletions src/reports/biospecimen-data/configInclude.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { QueryConfig, ReportConfig, SheetConfig } from '../types';

const biospecimens: SheetConfig = {
sheetName: 'Biospecimens',
root: 'biospecimens',
columns: [
{ field: 'fhir_id' },
{ field: 'external_id' },
{ field: 'files.biospecimens.biospecimen_id', header: 'Biospecimens Biospecimens Id' },
{
field: 'files.biospecimens.age_at_biospecimen_collection',
header: 'Biospecimens Age At Biospecimen Collection',
},
{ field: 'files.biospecimens.bio_repository', header: 'Biospecimens Bio Repository' },
{ field: 'files.biospecimens.biospecimen_type', header: 'Biospecimens Biospecimen Type' },
{ field: 'files.biospecimens.derived_sample_id', header: 'Biospecimens Derived Sample Id' },
{ field: 'files.biospecimens.derived_sample_type', header: 'Biospecimens Derived Sample Type' },
{ field: 'files.biospecimens.ncit_id_tissue_type', header: 'Biospecimens NCIT Id Tissue Type' },
{ field: 'files.biospecimens.sample_id', header: 'Biospecimens Sample Id' },
{ field: 'files.biospecimens.sample_type', header: 'Biospecimens Sample Type' },
],
sort: [
{
'files.biospecimens.biospecimen_id': {
order: 'asc',
},
},
{
fhir_id: {
order: 'asc',
},
},
],
};

const queryConfigs: QueryConfig = {
indexName: 'participant',
alias: 'participant_centric',
};

const sheetConfigs: SheetConfig[] = [biospecimens];

const reportConfig: ReportConfig = { queryConfigs, sheetConfigs };

export default reportConfig;
File renamed without changes.
7 changes: 6 additions & 1 deletion src/reports/biospecimen-data/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import { Request, Response } from 'express';
import { Client } from '@elastic/elasticsearch';
import generateReport from '../generateReport';
import reportConfig from './config';
import configKf from './configKf';
import configInclude from './configInclude';
import { PROJECT } from '../../env';
import { normalizeConfigs } from '../../utils/configUtils';
import ExtendedReportConfigs from '../../utils/extendedReportConfigs';
import { reportGenerationErrorHandler } from '../../errors';
import { ProjectType } from '../types';

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

const reportConfig = PROJECT.toLowerCase().trim() === ProjectType.kidsFirst ? configKf : configInclude;

let es = null;
try {
// prepare the ES client
Expand Down
Loading

0 comments on commit 97add34

Please sign in to comment.