From 0440e57d8299acfcb81bc9bf46e0a81d05a80ac4 Mon Sep 17 00:00:00 2001 From: Celine Pelletier Date: Thu, 26 Oct 2023 11:09:31 -0400 Subject: [PATCH] fix: SJIP-625 extract in function --- .../biospecimen-request/biospecimenRequestStats.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/reports/biospecimen-request/biospecimenRequestStats.ts b/src/reports/biospecimen-request/biospecimenRequestStats.ts index c6772ad..f122276 100644 --- a/src/reports/biospecimen-request/biospecimenRequestStats.ts +++ b/src/reports/biospecimen-request/biospecimenRequestStats.ts @@ -44,9 +44,9 @@ const biospecimenRequestStats = async (req: Request, res: Response): Promise b.participant_fhir_id)).size, - nb_available_samples: new Set(biospecimenForStudy.map(b => b.sample_id)).size, - nb_containers: new Set(biospecimenForStudy.map(b => b.container_id).filter(c => c)).size, + nb_participants: countDistinct(biospecimenForStudy.map(b => b.participant_fhir_id)), + nb_available_samples: countDistinct(biospecimenForStudy.map(b => b.sample_id)), + nb_containers: countDistinct(biospecimenForStudy.map(b => b.container_id).filter(c => c)), }); } } @@ -59,4 +59,6 @@ const biospecimenRequestStats = async (req: Request, res: Response): Promise new Set(array).size; + export default biospecimenRequestStats;