Skip to content

Commit

Permalink
improve search to filter variables on mapped concept IDs
Browse files Browse the repository at this point in the history
  • Loading branch information
vemonet committed Sep 30, 2024
1 parent b551535 commit 9639c4b
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 11 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,11 @@ Requirements: [Docker](https://docs.docker.com/engine/install/)
[email protected],[email protected]
```

> [!WARNING]
>
> * Make sure to add the user you will login with to the list of `ADMINS` if you want to be able to upload any cohort.
> * Get a token from Decentriq for your login email (the explorer needs a token to access Decentriq API)
2. Put the excel spreadsheet with all cohorts metadata in `data/iCARE4CVD_Cohorts.xlsx`. Uploaded cohorts will go to separated folders in `data/cohorts/`

3. Start the whole stack in development with docker compose, with hot reload for the frontend and backend:
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/VariablesList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ const VariablesList = ({cohortId, searchFilters = {searchQuery: ''}}: any) => {
.filter(
([variableName, variableData]: any) =>
variableName.toLowerCase().includes(searchFilters.searchQuery.toLowerCase()) ||
variableData.var_label.toLowerCase().includes(searchFilters.searchQuery.toLowerCase())
JSON.stringify(variableData).toLowerCase().includes(searchFilters.searchQuery.toLowerCase())
)
.filter(
([variableName, variableData]: any) =>
Expand Down
1 change: 1 addition & 0 deletions frontend/src/pages/cohorts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export default function CohortsList() {
})
.map(([, cohortData]) => cohortData);
}, [searchQuery, selectedDataTypes, selectedStudyTypes, selectedInstitutes, cohortsData]);
// NOTE: filtering variables is done in VariablesList component

return (
<main className="flex w-full p-4 bg-base-200 h-full min-h-screen space-x-4">
Expand Down
19 changes: 9 additions & 10 deletions frontend/src/pages/upload.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use client';

import React, {useState} from 'react';
import {Upload, UploadCloud} from 'react-feather';
import {Upload} from 'react-feather';
import {useCohorts} from '@/components/CohortsContext';
import {TrashIcon} from '@/components/Icons';
import {apiUrl} from '@/utils';
Expand All @@ -16,11 +16,11 @@ export default function UploadPage() {
const [publishedDCR, setPublishedDCR]: any = useState(null);
const [isLoading, setIsLoading] = useState(false);

// const cohortsNoVariables = cohortsData
// Show all cohorts for now, in case people need to reupload
const cohortsUserCanEdit = cohortsData ? Object.keys(cohortsData).filter(cohortId => cohortsData[cohortId]['can_edit']) : [];
// const cohortsUserCanEdit = cohortsData
// ? Object.keys(cohortsData).filter(cohortId => Object.keys(cohortsData[cohortId]['variables']).length === 0)
// : [];
// Show all cohorts for now, in case people need to reupload
const cohortsNoVariables = cohortsData ? Object.keys(cohortsData).filter(cohortId => true) : [];

const handleCohortIdChange = (event: any) => {
setCohortId(event.target.value);
Expand Down Expand Up @@ -112,13 +112,12 @@ export default function UploadPage() {
required
>
<option value="">Select the cohort to upload</option>
{cohortsNoVariables.map((cohortId: string) =>
cohortsData[cohortId]['can_edit'] ? (
<React.Fragment key={cohortId}>
<option value={cohortId}>{cohortId}</option>
</React.Fragment>
) : null
{cohortsUserCanEdit.map((cohortId: string) =>
<React.Fragment key={cohortId}>
<option value={cohortId}>{cohortId}</option>
</React.Fragment>
)}
{cohortsUserCanEdit.length === 0 && <option value="" disabled>No cohorts available</option>}
</select>
</div>

Expand Down

0 comments on commit 9639c4b

Please sign in to comment.