From 15e4b60dadf70f60903d5dc6f465b07b509151d3 Mon Sep 17 00:00:00 2001 From: Bryan Lai Date: Mon, 16 Sep 2024 17:54:34 -0400 Subject: [PATCH] fix validation --- src/pages/studyView/rfc80Tester.tsx | 2 ++ src/shared/api/validation.ts | 56 ++++++++++++++++++++--------- 2 files changed, 42 insertions(+), 16 deletions(-) diff --git a/src/pages/studyView/rfc80Tester.tsx b/src/pages/studyView/rfc80Tester.tsx index e8b37a4fa51..265579d0c79 100644 --- a/src/pages/studyView/rfc80Tester.tsx +++ b/src/pages/studyView/rfc80Tester.tsx @@ -113,6 +113,8 @@ export const RFC80Test = observer(function() { test.data, test.label, test.hash, + undefined, + undefined, col.assertResponse ).then((report: any) => { report.test = test; diff --git a/src/shared/api/validation.ts b/src/shared/api/validation.ts index 0c420d0046e..76f5953dce4 100644 --- a/src/shared/api/validation.ts +++ b/src/shared/api/validation.ts @@ -259,14 +259,36 @@ export function validate( if (body) { chXHR = Promise.resolve({ body, elapsedTime }); } else { - chXHR = $.ajax({ - method: 'post', - url: url, - data: JSON.stringify(params), - contentType: 'application/json', - }).then((body, state, xhr) => { - return { body, elapsedTime: xhr.getResponseHeader('elapsed-time') }; - }); + if (assertResponse && assertResponse[0] && assertResponse[0].attributeId) { + let data: any = {}; + data['attributes'] = [{ attributeId: assertResponse[0].attributeId }]; + if (params.studyViewFilter) { + const { + attributes, + ...filteredStudyViewFilter + } = params.studyViewFilter; + data['studyViewFilter'] = filteredStudyViewFilter; + } else { + data['studyViewFilter'] = params; + } + chXHR = $.ajax({ + method: 'post', + url: '/api/column-store/clinical-data-counts/fetch?', + data: JSON.stringify(data), + contentType: 'application/json', + }).then((body, state, xhr) => { + return { body, elapsedTime: xhr.getResponseHeader('elapsed-time') }; + }); + } else { + chXHR = $.ajax({ + method: 'post', + url: url, + data: JSON.stringify(params), + contentType: 'application/json', + }).then((body, state, xhr) => { + return { body, elapsedTime: xhr.getResponseHeader('elapsed-time') }; + }); + } } return chXHR @@ -295,14 +317,16 @@ export function validate( }); } else { - return { - label, - url: url, - hash: hash, - status: true, - data: params, - chDuration: parseFloat(elapsedTime), - }; + const result: any = compareCounts( + body, + assertResponse, + 'ClinicalDataCounts' + ); + result.url = url; + result.hash = hash; + result.data = params; + result.chDuration = parseFloat(elapsedTime); + return result; } }) .catch(() => {