diff --git a/package-lock.json b/package-lock.json index 1517a0d3c..2a24a8f36 100644 --- a/package-lock.json +++ b/package-lock.json @@ -27946,9 +27946,6 @@ "dependencies": { "copy-to-clipboard": "^3", "prop-types": "^15.5.8" - }, - "peerDependencies": { - "react": "^15.3.0 || ^16.0.0 || ^17.0.0" } }, "node_modules/react-datepicker": { diff --git a/src/components/CohortBuilder/Categories/Filter.js b/src/components/CohortBuilder/Categories/Filter.js index dd8343d76..9308f9251 100644 --- a/src/components/CohortBuilder/Categories/Filter.js +++ b/src/components/CohortBuilder/Categories/Filter.js @@ -9,10 +9,16 @@ import { compose } from 'recompose'; import { arrangerProjectId as ARRANGER_PROJECT_ID } from 'common/injectGlobals'; import { withApi } from 'services/api'; import { sqonShape } from 'shapes'; +import { addFilterToSQON } from 'store/sqonUtils'; import { ARRANGER_API_PARTICIPANT_INDEX_NAME } from '../common'; import { FieldFilterContainer } from '../FieldFilterContainer'; +const fieldsWithCustomIsTaggedQuery = [ + 'diagnoses.source_text_diagnosis', + 'diagnoses.ncit_id_diagnosis', +]; + /** * This component also assumes we are only modifying the first level of sqon */ @@ -61,12 +67,17 @@ const Filter = compose(withApi)( ? initialSqon.content.indexOf(contentWithField) : initialSqon.content.length, ]; + + const updatedSqon = fieldsWithCustomIsTaggedQuery.includes(field) + ? addFilterToSQON(initialSqon, 'diagnoses.is_tagged', ['true']) + : initialSqon; + const initializedSqon = { - ...initialSqon, + ...updatedSqon, content: contentWithField - ? initialSqon.content + ? updatedSqon.content : [ - ...initialSqon.content, + ...updatedSqon.content, { op: ['id', 'keyword', 'boolean'].includes(type) ? 'in' : 'between', content: { diff --git a/src/store/sqonUtils.tsx b/src/store/sqonUtils.tsx index 747995f93..78441962f 100644 --- a/src/store/sqonUtils.tsx +++ b/src/store/sqonUtils.tsx @@ -48,3 +48,11 @@ export const shapeFileTypeSqonFiltersForParticipantType = (fileCentricSqon: Sqon [], ); }; + +export const addFilterToSQON = (originalSqon: Sqon, field: string, values: string[]) => { + const newContent = [ + ...originalSqon.content, + { content: { field: field, value: values }, op: 'in' }, + ]; + return { ...originalSqon, ...{ content: newContent } }; +};