Skip to content

Commit ae07063

Browse files
feat(cohortMiddleWareEndpointUpdate): Initial commit (#1465)
* feat(cohortMiddleWareEndpointUpdate): Initial commit * feat(cohortMiddleWareEndpointUpdate): Removed unneeded console log
1 parent 40d9de1 commit ae07063

12 files changed

+39
-17
lines changed

src/Analysis/GWASApp/Components/Covariates/CustomDichotomousCovariates.jsx

+7-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ const CustomDichotomousCovariates = ({
1313
covariates,
1414
outcome,
1515
submitButtonLabel,
16+
selectedTeamProject,
1617
}) => {
1718
const [firstPopulation, setFirstPopulation] = useState(undefined);
1819
const [secondPopulation, setSecondPopulation] = useState(undefined);
@@ -86,12 +87,16 @@ const CustomDichotomousCovariates = ({
8687
</div>
8788
<div>
8889
<h3>Get Value 0</h3>
89-
<SelectCohortDropDown handleCohortSelect={setFirstPopulation} />
90+
<SelectCohortDropDown
91+
handleCohortSelect={setFirstPopulation}
92+
selectedTeamProject={selectedTeamProject}
93+
/>
9094
</div>
9195
<div>
9296
<h3>Get Value 1</h3>
9397
<SelectCohortDropDown
9498
handleCohortSelect={setSecondPopulation}
99+
selectedTeamProject={selectedTeamProject}
95100
/>
96101
</div>
97102
</div>
@@ -128,6 +133,7 @@ CustomDichotomousCovariates.propTypes = {
128133
outcome: PropTypes.object,
129134
submitButtonLabel: PropTypes.string,
130135
handleClose: PropTypes.func.isRequired,
136+
selectedTeamProject: PropTypes.string.isRequired,
131137
};
132138

133139
CustomDichotomousCovariates.defaultProps = {

src/Analysis/GWASApp/Components/Covariates/CustomDichotomousCovariates.stories.jsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ SuccessAndZeroOverlapCases.parameters = {
7272
}
7373
),
7474
rest.get(
75-
'http://:cohortmiddlewarepath/cohort-middleware/cohortdefinition-stats/by-source-id/:sourceid',
75+
'http://:cohortmiddlewarepath/cohort-middleware/cohortdefinition-stats/by-source-id/:sourceid/by-team-project?team-project=:selectedTeamProject',
7676
(req, res, ctx) => {
7777
const { cohortmiddlewarepath } = req.params;
7878
const { cohortdefinitionA } = req.params;
@@ -132,7 +132,7 @@ ErrorCase.parameters = {
132132
msw: {
133133
handlers: [
134134
rest.get(
135-
'http://:cohortmiddlewarepath/cohort-middleware/cohortdefinition-stats/by-source-id/:sourceid',
135+
'http://:cohortmiddlewarepath/cohort-middleware/cohortdefinition-stats/by-source-id/:sourceid/by-team-project?team-project=:selectedTeamProject',
136136
(req, res, ctx) => res(ctx.delay(800), ctx.status(403))
137137
),
138138
],

src/Analysis/GWASApp/Components/SelectCohort/SelectCohort.jsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import CohortDefinitions from './Utils/CohortDefinitions';
77
import SearchBar from '../SearchBar/SearchBar';
88
import './SelectCohort.css';
99

10-
const SelectCohort = ({ selectedCohort, handleCohortSelect }) => {
10+
const SelectCohort = ({ selectedCohort, handleCohortSelect, selectedTeamProject }) => {
1111
const [cohortSearchTerm, setCohortSearchTerm] = useState('');
1212

1313
const handleCohortSearch = (searchTerm) => {
@@ -36,6 +36,7 @@ const SelectCohort = ({ selectedCohort, handleCohortSelect }) => {
3636
selectedCohort={selectedCohort}
3737
handleCohortSelect={handleCohortSelect}
3838
searchTerm={cohortSearchTerm}
39+
selectedTeamProject={selectedTeamProject}
3940
/>
4041
</div>
4142
</div>
@@ -47,6 +48,7 @@ const SelectCohort = ({ selectedCohort, handleCohortSelect }) => {
4748
SelectCohort.propTypes = {
4849
selectedCohort: PropTypes.any,
4950
handleCohortSelect: PropTypes.func.isRequired,
51+
selectedTeamProject: PropTypes.string.isRequired,
5052
};
5153
SelectCohort.defaultProps = {
5254
selectedCohort: null,

src/Analysis/GWASApp/Components/SelectCohort/SelectCohort.stories.jsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ MockedSuccess.parameters = {
7373
handlers: [
7474
///cohort-middleware/cohortdefinition-stats/by-source-id/1
7575
rest.get(
76-
'http://:cohortmiddlewarepath/cohort-middleware/cohortdefinition-stats/by-source-id/:sourceid',
76+
'http://:cohortmiddlewarepath/cohort-middleware/cohortdefinition-stats/by-source-id/:sourceid/by-team-project?team-project=:selectedTeamProject',
7777
(req, res, ctx) => {
7878
const { cohortmiddlewarepath } = req.params;
7979
const { sourceid } = req.params;
@@ -247,7 +247,7 @@ MockedError.parameters = {
247247
msw: {
248248
handlers: [
249249
rest.get(
250-
'http://:cohortmiddlewarepath/cohort-middleware/cohortdefinition-stats/by-source-id/:sourceid',
250+
'http://:cohortmiddlewarepath/cohort-middleware/cohortdefinition-stats/by-source-id/:sourceid/by-team-project?team-project=:selectedTeamProject',
251251
(req, res, ctx) => res(ctx.delay(800), ctx.status(403))
252252
),
253253
],

src/Analysis/GWASApp/Components/SelectCohort/SelectCohortDropDown.jsx

+4-3
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ import queryConfig from '../../../SharedUtils/QueryConfig';
77
import { useFetch } from '../../Utils/formHooks';
88
import { useSourceContext } from '../../Utils/Source';
99

10-
const SelectCohortDropDown = ({ handleCohortSelect }) => {
10+
const SelectCohortDropDown = ({ handleCohortSelect, selectedTeamProject }) => {
1111
const { source } = useSourceContext();
1212
const cohorts = useQuery(
13-
['cohortdefinitions', source],
14-
() => fetchCohortDefinitions(source),
13+
['cohortdefinitions', source, selectedTeamProject],
14+
() => fetchCohortDefinitions(source, selectedTeamProject),
1515
queryConfig,
1616
);
1717
const fetchedCohorts = useFetch(cohorts, 'cohort_definitions_and_stats');
@@ -53,6 +53,7 @@ const SelectCohortDropDown = ({ handleCohortSelect }) => {
5353

5454
SelectCohortDropDown.propTypes = {
5555
handleCohortSelect: PropTypes.any.isRequired,
56+
selectedTeamProject: PropTypes.string.isRequired,
5657
};
5758

5859
export default SelectCohortDropDown;

src/Analysis/GWASApp/Components/SelectCohort/SelectCohortDropDown.stories.jsx

+2-3
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,8 @@ export const MockedSuccess = MockTemplate.bind({});
4040
MockedSuccess.parameters = {
4141
msw: {
4242
handlers: [
43-
///cohort-middleware/cohortdefinition-stats/by-source-id/1
4443
rest.get(
45-
'http://:cohortmiddlewarepath/cohort-middleware/cohortdefinition-stats/by-source-id/:sourceid',
44+
'http://:cohortmiddlewarepath/cohort-middleware/cohortdefinition-stats/by-source-id/:sourceid/by-team-project?team-project=:selectedTeamProject',
4645
(req, res, ctx) => {
4746
const { cohortmiddlewarepath } = req.params;
4847
const { sourceid } = req.params;
@@ -217,7 +216,7 @@ MockedError.parameters = {
217216
msw: {
218217
handlers: [
219218
rest.get(
220-
'http://:cohortmiddlewarepath/cohort-middleware/cohortdefinition-stats/by-source-id/:sourceid',
219+
'http://:cohortmiddlewarepath/cohort-middleware/cohortdefinition-stats/by-source-id/:sourceid/by-team-project?team-project=:selectedTeamProject',
221220
(req, res, ctx) => res(ctx.delay(800), ctx.status(403))
222221
),
223222
],

src/Analysis/GWASApp/Components/SelectCohort/Utils/CohortDefinitions.jsx

+5-2
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,12 @@ const CohortDefinitions = ({
1111
selectedCohort = undefined,
1212
handleCohortSelect,
1313
searchTerm,
14+
selectedTeamProject,
1415
}) => {
1516
const { source } = useSourceContext();
1617
const cohorts = useQuery(
17-
['cohortdefinitions', source],
18-
() => fetchCohortDefinitions(source),
18+
['cohortdefinitions', source, selectedTeamProject],
19+
() => fetchCohortDefinitions(source, selectedTeamProject),
1920
queryConfig,
2021
);
2122
const fetchedCohorts = useFetch(cohorts, 'cohort_definitions_and_stats');
@@ -43,6 +44,7 @@ const CohortDefinitions = ({
4344
key: 'size',
4445
},
4546
];
47+
if (cohorts?.status === 'error') return <React.Fragment>Error getting data for table</React.Fragment>;
4648

4749
return cohorts?.status === 'success' ? (
4850
<Table
@@ -76,6 +78,7 @@ CohortDefinitions.propTypes = {
7678
selectedCohort: PropTypes.any,
7779
handleCohortSelect: PropTypes.any.isRequired,
7880
searchTerm: PropTypes.string.isRequired,
81+
selectedTeamProject: PropTypes.string.isRequired,
7982
};
8083

8184
CohortDefinitions.defaultProps = {

src/Analysis/GWASApp/GWASContainer.jsx

+3
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ const GWASContainer = () => {
2626
<SelectStudyPopulation
2727
selectedCohort={state.selectedStudyPopulationCohort}
2828
dispatch={dispatch}
29+
selectedTeamProject={state.selectedTeamProject}
2930
/>
3031
</div>
3132
);
@@ -36,6 +37,7 @@ const GWASContainer = () => {
3637
outcome={state.outcome}
3738
covariates={state.covariates}
3839
dispatch={dispatch}
40+
selectedTeamProject={state.selectedTeamProject}
3941
/>
4042
);
4143
case 2:
@@ -45,6 +47,7 @@ const GWASContainer = () => {
4547
outcome={state.outcome}
4648
covariates={state.covariates}
4749
dispatch={dispatch}
50+
selectedTeamProject={state.selectedTeamProject}
4851
/>
4952
);
5053
case 3:

src/Analysis/GWASApp/Steps/SelectCovariates/SelectCovariates.jsx

+3
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ const SelectCovariates = ({
1313
studyPopulationCohort,
1414
outcome,
1515
covariates,
16+
selectedTeamProject,
1617
}) => {
1718
const [selectionMode, setSelectionMode] = useState('');
1819
useEffect(() => {
@@ -76,6 +77,7 @@ const SelectCovariates = ({
7677
});
7778
}}
7879
submitButtonLabel={'Add'}
80+
selectedTeamProject={selectedTeamProject}
7981
/>
8082
</div>
8183
)}
@@ -137,6 +139,7 @@ SelectCovariates.propTypes = {
137139
studyPopulationCohort: PropTypes.object.isRequired,
138140
outcome: PropTypes.object.isRequired,
139141
covariates: PropTypes.array.isRequired,
142+
selectedTeamProject: PropTypes.string.isRequired,
140143
};
141144

142145
export default SelectCovariates;

src/Analysis/GWASApp/Steps/SelectOutcome/SelectOutcome.jsx

+3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ const SelectOutcome = ({
1212
studyPopulationCohort,
1313
outcome,
1414
covariates,
15+
selectedTeamProject,
1516
}) => {
1617
const [selectionMode, setSelectionMode] = useState('');
1718
useEffect(
@@ -67,6 +68,7 @@ const SelectOutcome = ({
6768
payload: chosenOutcome,
6869
});
6970
}}
71+
selectedTeamProject={selectedTeamProject}
7072
/>
7173
</div>
7274
);
@@ -131,6 +133,7 @@ SelectOutcome.propTypes = {
131133
studyPopulationCohort: PropTypes.object.isRequired,
132134
outcome: PropTypes.object,
133135
covariates: PropTypes.array,
136+
selectedTeamProject: PropTypes.string.isRequired,
134137
};
135138

136139
SelectOutcome.defaultProps = {

src/Analysis/GWASApp/Steps/SelectStudyPopulation/SelectStudyPopulation.jsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import PropTypes from 'prop-types';
33
import ACTIONS from '../../Utils/StateManagement/Actions';
44
import CohortSelect from '../../Components/SelectCohort/SelectCohort';
55

6-
const SelectStudyPopulation = ({ selectedCohort, dispatch }) => {
6+
const SelectStudyPopulation = ({ selectedCohort, dispatch, selectedTeamProject }) => {
77
const handleStudyPopulationSelect = (selectedRow) => {
88
dispatch({
99
type: ACTIONS.SET_SELECTED_STUDY_POPULATION_COHORT,
@@ -16,6 +16,7 @@ const SelectStudyPopulation = ({ selectedCohort, dispatch }) => {
1616
<CohortSelect
1717
selectedCohort={selectedCohort}
1818
handleCohortSelect={handleStudyPopulationSelect}
19+
selectedTeamProject={selectedTeamProject}
1920
/>
2021
</div>
2122
);
@@ -24,6 +25,7 @@ const SelectStudyPopulation = ({ selectedCohort, dispatch }) => {
2425
SelectStudyPopulation.propTypes = {
2526
dispatch: PropTypes.func.isRequired,
2627
selectedCohort: PropTypes.object,
28+
selectedTeamProject: PropTypes.string.isRequired,
2729
};
2830
SelectStudyPopulation.defaultProps = { selectedCohort: null };
2931
export default SelectStudyPopulation;

src/Analysis/GWASApp/Utils/cohortMiddlewareApi.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,8 @@ export const fetchCovariateStats = async (
153153
return response.json();
154154
};
155155

156-
export const fetchCohortDefinitions = async (sourceId) => {
157-
const cohortEndPoint = `${cohortMiddlewarePath}cohortdefinition-stats/by-source-id/${sourceId}`;
156+
export const fetchCohortDefinitions = async (sourceId, selectedTeamProject) => {
157+
const cohortEndPoint = `${cohortMiddlewarePath}cohortdefinition-stats/by-source-id/${sourceId}/by-team-project?team-project=${selectedTeamProject}`;
158158
const response = await fetch(cohortEndPoint);
159159
if (!response.ok) {
160160
const message = `An error has occured: ${response.status}`;

0 commit comments

Comments
 (0)