From c9e219395964920b442a05d93f2e62b49fff54d1 Mon Sep 17 00:00:00 2001 From: Tatiana Date: Thu, 19 Sep 2024 10:27:45 -0700 Subject: [PATCH] Remove StudyID Requirement for Single Study in Custom Selection --- .../CustomCaseSelectionUtils.tsx | 25 +++++++++++++++---- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/src/pages/studyView/addChartButton/customCaseSelection/CustomCaseSelectionUtils.tsx b/src/pages/studyView/addChartButton/customCaseSelection/CustomCaseSelectionUtils.tsx index dff42516fe7..0ba1ab5cecd 100644 --- a/src/pages/studyView/addChartButton/customCaseSelection/CustomCaseSelectionUtils.tsx +++ b/src/pages/studyView/addChartButton/customCaseSelection/CustomCaseSelectionUtils.tsx @@ -66,16 +66,20 @@ export function getLine(line: string): InputLine { }; const content = line.split(':'); - if (content.length === 1) { - parsedResult.caseId = content[0]; - } else if (content.length > 1) { - parsedResult.studyId = content[0]; - const groupInfo = content[1].split(/\s|\t/g); + const setCaseIdAndValue = (groupInfo: string[]) => { if (groupInfo.length > 1) { parsedResult.value = groupInfo[1]; } parsedResult.caseId = groupInfo[0]; + }; + if (content.length === 1) { + parsedResult.caseId = content[0]; + setCaseIdAndValue(content[0].split(/\s|\t/g)); + } else if (content.length > 1) { + parsedResult.studyId = content[0]; + setCaseIdAndValue(content[1].split(/\s|\t/g)); } + return parsedResult; } @@ -348,6 +352,17 @@ export function parseContent( warning: [], }; let lines: InputLine[] = getLines(content); + if (isSingleStudy) { + lines = lines.map(line => { + if (!line.studyId) { + line.studyId = selectedStudies[0]; + line.line = `${line.studyId}:${line.line}`; + } + + return line; + }); + } + if (lines.length > 0) { if (needToValidate) { const result = validateLines(