Skip to content

Commit 7cdaf66

Browse files
authored
Prevent duplicate VUS from being added (oncokb#550)
1 parent 8c5dbb9 commit 7cdaf66

File tree

2 files changed

+28
-13
lines changed

2 files changed

+28
-13
lines changed

src/main/webapp/app/pages/curation/CurationPage.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,19 +168,19 @@ export const CurationPage = (props: ICurationPageProps) => {
168168
}
169169

170170
const oncogeneRef = labelsToRefs[GENE_TYPE.ONCOGENE].current!;
171-
const tumorSupressorRef = labelsToRefs[GENE_TYPE.TUMOR_SUPPRESSOR].current!;
171+
const tumorSuppressorRef = labelsToRefs[GENE_TYPE.TUMOR_SUPPRESSOR].current!;
172172
const neitherRef = labelsToRefs[GENE_TYPE.NEITHER].current!;
173173
const unknownRef = labelsToRefs[GENE_TYPE.INSUFFICIENT_EVIDENCE].current!;
174174

175175
if (label === GENE_TYPE.TUMOR_SUPPRESSOR.toString() || label === GENE_TYPE.ONCOGENE.toString()) {
176176
unknownRef.checked && unknownRef.click();
177177
neitherRef.checked && neitherRef.click();
178178
} else if (label === GENE_TYPE.INSUFFICIENT_EVIDENCE.toString()) {
179-
tumorSupressorRef.checked && tumorSupressorRef.click();
179+
tumorSuppressorRef.checked && tumorSuppressorRef.click();
180180
oncogeneRef.checked && oncogeneRef.click();
181181
neitherRef.checked && neitherRef.click();
182182
} else if (label === GENE_TYPE.NEITHER.toString()) {
183-
tumorSupressorRef.checked && tumorSupressorRef.click();
183+
tumorSuppressorRef.checked && tumorSuppressorRef.click();
184184
oncogeneRef.checked && oncogeneRef.click();
185185
unknownRef.checked && unknownRef.click();
186186
}

src/main/webapp/app/shared/modal/AddVusModal.tsx

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, { useEffect, useRef, useState } from 'react';
22
import CreatableSelect from 'react-select/creatable';
3-
import { Mutation, MutationList, VusObjList } from '../model/firebase/firebase.model';
3+
import { MutationList, VusObjList } from '../model/firebase/firebase.model';
44
import { parseAlterationName } from '../util/utils';
55
import _ from 'lodash';
66
import { notifyError } from 'app/oncokb-commons/components/util/NotificationUtils';
@@ -107,18 +107,33 @@ const AddVusModal = (props: IAddVusModalProps) => {
107107
};
108108

109109
const filterAlterationsAndNotify = (variant: string) => {
110-
const currentVariants = variants.map(o => o.label.toLowerCase());
110+
const result: string[] = [];
111111
const alterations = parseAlterationName(variant);
112-
const filteredAlterations = alterations.filter(alt => {
113-
if (currentVariants.includes(alt.alteration.toLowerCase())) {
114-
return false;
112+
// should only have a single alteration
113+
for (const { alteration } of alterations) {
114+
const dropdownAlreadyHasVariant = variants.some(({ label }) => {
115+
return label.toLowerCase() === alteration.toLowerCase();
116+
});
117+
118+
const vusTableAlreadyHasVariant = Object.values(props.vusList ?? {}).some(({ name }) => {
119+
return name.toLowerCase() === alteration.toLowerCase();
120+
});
121+
122+
const alreadyHasVariantInMutationList = Object.values(mutationList ?? {}).some(({ name }) => {
123+
return name.toLowerCase() === alteration.toLowerCase();
124+
});
125+
126+
if (dropdownAlreadyHasVariant) {
127+
notifyError(new Error(`${alteration} is already selected. The duplicate alteration(s) was not added.`));
128+
} else if (vusTableAlreadyHasVariant) {
129+
notifyError(new Error(`${alteration} is already in the VUS table. The duplicate alteration(s) was not added.`));
130+
} else if (alreadyHasVariantInMutationList) {
131+
notifyError(new Error(`${alteration} is already in the Mutation List. The duplicate alteration(s) was not added.`));
132+
} else {
133+
result.push(alteration);
115134
}
116-
return true;
117-
});
118-
if (alterations.length !== filteredAlterations.length) {
119-
notifyError(new Error('Duplicate alteration(s) removed'));
120135
}
121-
return filteredAlterations.map(a => a.alteration);
136+
return result;
122137
};
123138

124139
const selectComponent = (

0 commit comments

Comments
 (0)