Skip to content

Commit

Permalink
fix: #3344 diagnosis fields show incorrect No data count (#3348)
Browse files Browse the repository at this point in the history
  • Loading branch information
adipaul1981 authored Jun 23, 2021
1 parent 718ff31 commit 1a37467
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
3 changes: 0 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 14 additions & 3 deletions src/components/CohortBuilder/Categories/Filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down Expand Up @@ -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: {
Expand Down
8 changes: 8 additions & 0 deletions src/store/sqonUtils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 } };
};

0 comments on commit 1a37467

Please sign in to comment.