Skip to content

Commit

Permalink
fix: SJIP-812 replace ethnicity with race in statistic route (#142)
Browse files Browse the repository at this point in the history
  • Loading branch information
aperron-ferlab authored Apr 25, 2024
1 parent 76703e7 commit 8bfb201
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
20 changes: 13 additions & 7 deletions src/app.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,19 @@ describe('Express app (without Arranger)', () => {
T21: 7266,
D21: 1430,
},
ethnicity: {
'Not Hispanic or Latino': 6710,
'Hispanic or Latino': 850,
Unknown: 579,
'asked but unknown': 494,
NoInformation: 30,
unknown: 10,
race: {
White: 7029,
'Black or African American': 618,
Unknown: 408,
Asian: 269,
NoInformation: 131,
other: 66,
'asked but unknown': 58,
'More than one race': 37,
unknown: 35,
'American Indian or Alaska Native': 34,
'Native Hawaiian or Other Pacific Islander': 8,
'not available': 3,
},
diagnosis: [
{
Expand Down
10 changes: 5 additions & 5 deletions src/endpoints/statistics/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export type Statistics = {
transcriptomes: number;
sex: Record<string, number>;
downSyndromeStatus: Record<string, number>;
ethnicity: Record<string, number>;
race: Record<string, number>;
diagnosis: Diagnosis[];
};

Expand Down Expand Up @@ -236,7 +236,7 @@ export const fetchDemographicsStats = async (client: Client): Promise<Record<str
{ index: esParticipantIndex },
{ size: 0, aggs: { down_syndrome_status: { terms: { field: 'down_syndrome_status', size: 10 } } } },
{ index: esParticipantIndex },
{ size: 0, aggs: { ethnicity: { terms: { field: 'ethnicity', size: 10 } } } },
{ size: 0, aggs: { race: { terms: { field: 'race', size: 20 } } } },
],
});

Expand All @@ -251,12 +251,12 @@ export const fetchDemographicsStats = async (client: Client): Promise<Record<str
},
{},
);
const ethnicity = response.body.responses[2].aggregations.ethnicity.buckets.reduce((acc, curr) => {
const race = response.body.responses[2].aggregations.race.buckets.reduce((acc, curr) => {
acc[curr.key] = curr.doc_count;
return acc;
}, {});

return [sex, downSyndromeStatus, ethnicity];
return [sex, downSyndromeStatus, race];
};

export const fetchTopDiagnosis = async (client: Client): Promise<Diagnosis[]> => {
Expand Down Expand Up @@ -318,7 +318,7 @@ export const getStatistics = async (): Promise<Statistics> => {
transcriptomes: results[8],
sex: results[9][0],
downSyndromeStatus: results[9][1],
ethnicity: results[9][2],
race: results[9][2],
diagnosis,
};
};
Expand Down

0 comments on commit 8bfb201

Please sign in to comment.