Skip to content

Commit

Permalink
refacto filter components
Browse files Browse the repository at this point in the history
  • Loading branch information
aetchego committed Dec 10, 2024
1 parent 9540e29 commit 136bf69
Show file tree
Hide file tree
Showing 41 changed files with 403 additions and 655 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ const EpisodeConstraints: React.FC<EpisodeConstraintsProps> = ({ constraints, on
</Grid>
<RadioGroup
row
selectedValue={radioValues}
onchange={(e) => {
value={radioValues}
onChange={(e) => {
if (
radioValues === TemporalConstraintsKind.PARTIAL_EPISODE_CONSTRAINT &&
constraints.find(
Expand All @@ -101,7 +101,7 @@ const EpisodeConstraints: React.FC<EpisodeConstraintsProps> = ({ constraints, on
onChangeValue(e as TemporalConstraintsKind)
}
}}
items={episodesTemporalConstraintsTypes}
options={episodesTemporalConstraintsTypes}
style={{ margin: '1em', justifyContent: 'space-around' }}
/>
</Grid>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ const StayConstraints: React.FC<StayConstraintsProps> = ({ constraints, onChange
<Typography variant="h3">Contraintes sur les séjours</Typography>
<RadioGroup
row
selectedValue={radioValues}
onchange={(e) => {
value={radioValues}
onChange={(e) => {
if (
radioValues === TemporalConstraintsKind.PARTIAL_CONSTRAINT &&
constraints.find((constraint) => constraint.constraintType === TemporalConstraintsKind.SAME_ENCOUNTER)
Expand All @@ -91,7 +91,7 @@ const StayConstraints: React.FC<StayConstraintsProps> = ({ constraints, onChange
onChangeValue(e as TemporalConstraintsKind)
}
}}
items={temporalConstraintsTypes}
options={temporalConstraintsTypes}
style={{ margin: '1em', justifyContent: 'space-around' }}
/>
</Grid>
Expand Down
7 changes: 4 additions & 3 deletions src/components/Dashboard/BiologyList/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import {
fetchAnabioCodes as fetchAnabioCodesApi
} from 'services/aphp/serviceBiology'
import { checkIfPageAvailable, cleanSearchParams, handlePageError } from 'utils/paginationUtils'
import SelectInput from 'components/Filters/SelectInput'
import MultiSelectInput from 'components/Filters/MultiSelectInput'

type BiologyListProps = {
deidentified?: boolean
Expand Down Expand Up @@ -80,6 +80,7 @@ const BiologyList = ({ deidentified }: BiologyListProps) => {
},
{ changeOrderBy, changeSearchInput, addFilters, removeFilter, addSearchCriterias }
] = useSearchCriterias(initBioSearchCriterias)
console.log("test filters", filters)

Check failure on line 83 in src/components/Dashboard/BiologyList/index.tsx

View workflow job for this annotation

GitHub Actions / test

Replace `"test·filters"` with `'test·filters'`
const filtersAsArray = useMemo(
() =>
selectFiltersAsArray({
Expand Down Expand Up @@ -334,7 +335,7 @@ const BiologyList = ({ deidentified }: BiologyListProps) => {
value={executiveUnits}
name={FilterKeys.EXECUTIVE_UNITS}
/>
<SelectInput
<MultiSelectInput
value={encounterStatus}
name={FilterKeys.ENCOUNTER_STATUS}
options={encounterStatusList}
Expand Down Expand Up @@ -491,7 +492,7 @@ const BiologyList = ({ deidentified }: BiologyListProps) => {
/>
</Grid>
<Grid item xs={12}>
<SelectInput
<MultiSelectInput
disabled={isReadonlyFilterInfoModal}
value={selectedSavedFilter?.filterParams.filters.encounterStatus || []}
name={FilterKeys.ENCOUNTER_STATUS}
Expand Down
24 changes: 16 additions & 8 deletions src/components/Dashboard/Documents/Documents.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import useSearchCriterias, { initAllDocsSearchCriterias } from 'reducers/searchC
import { AlertWrapper } from 'components/ui/Alert'
import DatesRangeFilter from 'components/Filters/DatesRangeFilter'
import DocTypesFilter from 'components/Filters/DocTypesFilter'
import DocStatusFilter from 'components/Filters/DocStatusFilter'
import ExecutiveUnitsFilter from 'components/Filters/ExecutiveUnitsFilter'
import { ResourceType } from 'types/requestCriterias'
import { Save, SavedSearch } from '@mui/icons-material'
Expand All @@ -43,7 +42,7 @@ import { useSearchParams } from 'react-router-dom'
import { checkIfPageAvailable, cleanSearchParams, handlePageError } from 'utils/paginationUtils'
import { CanceledError } from 'axios'
import { DocumentReference } from 'fhir/r4'
import SelectInput from 'components/Filters/SelectInput'
import MultiSelectInput from 'components/Filters/MultiSelectInput'

type DocumentsProps = {
deidentified: boolean
Expand Down Expand Up @@ -127,7 +126,10 @@ const Documents: React.FC<DocumentsProps> = ({ deidentified }) => {
const controllerRef = useRef<AbortController>(new AbortController())
const isFirstRender = useRef(true)

const docStatusesList = [FilterByDocumentStatus.VALIDATED, FilterByDocumentStatus.NOT_VALIDATED]
const docStatusesList = [
{ id: FilterByDocumentStatus.VALIDATED, label: FilterByDocumentStatus.VALIDATED },
{ id: FilterByDocumentStatus.NOT_VALIDATED, label: FilterByDocumentStatus.NOT_VALIDATED }
]

const fetchDocumentsList = async () => {
try {
Expand Down Expand Up @@ -391,15 +393,20 @@ const Documents: React.FC<DocumentsProps> = ({ deidentified }) => {
placeholder="'Exemple: 8000000000001,8000000000002'"
/>
)}
<DocStatusFilter docStatusesList={docStatusesList} name={FilterKeys.DOC_STATUSES} value={docStatuses} />
<MultiSelectInput
options={docStatusesList}
name={FilterKeys.DOC_STATUSES}
value={docStatuses}
label="Statut de documents :"
/>
<DocTypesFilter allDocTypesList={allDocTypesList.docTypes} value={docTypes} name={FilterKeys.DOC_TYPES} />
<DatesRangeFilter values={[startDate, endDate]} names={[FilterKeys.START_DATE, FilterKeys.END_DATE]} />
<ExecutiveUnitsFilter
sourceType={SourceType.DOCUMENT}
value={executiveUnits}
name={FilterKeys.EXECUTIVE_UNITS}
/>
<SelectInput
<MultiSelectInput
value={encounterStatus}
name={FilterKeys.ENCOUNTER_STATUS}
options={encounterStatusList}
Expand Down Expand Up @@ -534,11 +541,12 @@ const Documents: React.FC<DocumentsProps> = ({ deidentified }) => {
)}
</Grid>
<Grid item>
<DocStatusFilter
<MultiSelectInput
disabled={isReadonlyFilterInfoModal}
docStatusesList={docStatusesList}
options={docStatusesList}
value={selectedSavedFilter?.filterParams.filters.docStatuses || []}
name={FilterKeys.DOC_STATUSES}
label="Statut de documents :"
/>
</Grid>
<Grid item>
Expand Down Expand Up @@ -568,7 +576,7 @@ const Documents: React.FC<DocumentsProps> = ({ deidentified }) => {
/>
</Grid>
<Grid item>
<SelectInput
<MultiSelectInput
label="Statut de la visite associée :"
disabled={isReadonlyFilterInfoModal}
value={selectedSavedFilter?.filterParams.filters.encounterStatus || []}
Expand Down
2 changes: 1 addition & 1 deletion src/components/Dashboard/ExportModal/exportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ const fetchDocumentsCount = async (cohortId: string, documentsFilters?: SearchCr
size: 0,
_list: [cohortId],
searchBy: documentsFilters.searchBy,
docStatuses: docStatuses,
docStatuses: docStatuses.map((obj) => obj.id),
_text: documentsFilters.searchInput,
type: docTypes.map((docType) => docType.code).join(),
'encounter-identifier': nda,
Expand Down
4 changes: 2 additions & 2 deletions src/components/Dashboard/FormsList/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { useSearchParams } from 'react-router-dom'
import { checkIfPageAvailable, cleanSearchParams, handlePageError } from 'utils/paginationUtils'
import Chip from 'components/ui/Chip'
import TextInput from 'components/Filters/TextInput'
import SelectInput from 'components/Filters/SelectInput'
import MultiSelectInput from 'components/Filters/MultiSelectInput'

const FormsList = () => {
const theme = useTheme()
Expand Down Expand Up @@ -218,7 +218,7 @@ const FormsList = () => {
value={executiveUnits}
name={FilterKeys.EXECUTIVE_UNITS}
/>
<SelectInput
<MultiSelectInput
label="Statut de la visite associée :"
value={encounterStatus}
name={FilterKeys.ENCOUNTER_STATUS}
Expand Down
17 changes: 6 additions & 11 deletions src/components/Dashboard/ImagingList/index.tsx
Original file line number Diff line number Diff line change
@@ -1,26 +1,20 @@
import React, { useState, useEffect, useRef, useMemo, useContext } from 'react'
import useSearchCriterias, { initImagingCriterias } from 'reducers/searchCriteriasReducer'
import services from 'services/aphp'

import { CircularProgress, Grid, Tooltip } from '@mui/material'
import { FilterList, Save, SavedSearch } from '@mui/icons-material'

import Button from 'components/ui/Button'
import Chip from 'components/ui/Chip'
import DataTableImaging from 'components/DataTable/DataTableImaging'
import DatesRangeFilter from 'components/Filters/DatesRangeFilter'
import DisplayDigits from 'components/ui/Display/DisplayDigits'
import ExecutiveUnitsFilter from 'components/Filters/ExecutiveUnitsFilter'
import Modal from 'components/ui/Modal'
import ModalityFilter from 'components/Filters/ModalityFilter/ModalityFilter'
import SearchInput from 'components/ui/Searchbar/SearchInput'

import { CohortImaging, LoadingStatus, DTTB_ResultsType as ResultsType } from 'types'
import { Direction, FilterKeys, ImagingFilters, Order } from 'types/searchCriterias'

import { cancelPendingRequest } from 'utils/abortController'
import { selectFiltersAsArray } from 'utils/filters'

import { CanceledError } from 'axios'
import { AlertWrapper } from 'components/ui/Alert'
import { ResourceType } from 'types/requestCriterias'
Expand All @@ -34,7 +28,7 @@ import { Hierarchy } from 'types/hierarchy'
import { AppConfig } from 'config'
import { useSearchParams } from 'react-router-dom'
import { checkIfPageAvailable, cleanSearchParams, handlePageError } from 'utils/paginationUtils'
import SelectInput from 'components/Filters/SelectInput'
import MultiSelectInput from 'components/Filters/MultiSelectInput'

type ImagingListProps = {
deidentified?: boolean
Expand Down Expand Up @@ -299,14 +293,14 @@ const ImagingList = ({ deidentified }: ImagingListProps) => {
placeholder="'Exemple: 8000000000001,8000000000002'"
/>
)}
<ModalityFilter value={modality} name={FilterKeys.MODALITY} modalitiesList={allModalities} />
<MultiSelectInput value={modality} name={FilterKeys.MODALITY} options={allModalities} label="Modalités :" />
<DatesRangeFilter values={[startDate, endDate]} names={[FilterKeys.START_DATE, FilterKeys.END_DATE]} />
<ExecutiveUnitsFilter
sourceType={SourceType.IMAGING}
value={executiveUnits}
name={FilterKeys.EXECUTIVE_UNITS}
/>
<SelectInput
<MultiSelectInput
value={encounterStatus}
name={FilterKeys.ENCOUNTER_STATUS}
options={encounterStatusList}
Expand Down Expand Up @@ -407,11 +401,12 @@ const ImagingList = ({ deidentified }: ImagingListProps) => {
placeholder="Exemple: 6601289264,141740347"
/>
)}
<ModalityFilter
<MultiSelectInput
disabled={isReadonlyFilterInfoModal}
value={selectedSavedFilter?.filterParams.filters.modality || []}
name={FilterKeys.MODALITY}
modalitiesList={allModalities}
options={allModalities}
label="Modalités :"
/>
<DatesRangeFilter
disabled={isReadonlyFilterInfoModal}
Expand Down
21 changes: 11 additions & 10 deletions src/components/Dashboard/MedicationList/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { MedicationAdministration, MedicationRequest } from 'fhir/r4'

import { Chip, CircularProgress, Grid, Tooltip, useMediaQuery, useTheme } from '@mui/material'
import { Save, SavedSearch, FilterList } from '@mui/icons-material'
import AdministrationTypesFilter from 'components/Filters/AdministrationTypesFilter'
import Button from 'components/ui/Button'
import DataTableMedication from 'components/DataTable/DataTableMedication'
import DatesRangeFilter from 'components/Filters/DatesRangeFilter'
Expand All @@ -13,7 +12,7 @@ import ExecutiveUnitsFilter from 'components/Filters/ExecutiveUnitsFilter'
import List from 'components/ui/List'
import Modal from 'components/ui/Modal'
import { medicationTabs } from 'components/Patient/PatientMedication/PatientMedication'
import SelectInput from 'components/Filters/SelectInput'
import MultiSelectInput from 'components/Filters/MultiSelectInput'
import SearchInput from 'components/ui/Searchbar/SearchInput'
import Tabs from 'components/ui/Tabs'
import TextInput from 'components/Filters/TextInput'
Expand Down Expand Up @@ -364,18 +363,19 @@ const MedicationList = ({ deidentified }: MedicationListProps) => {
/>
)}
{selectedTab.id === ResourceType.MEDICATION_REQUEST && prescriptionTypes && (
<SelectInput
<MultiSelectInput
value={prescriptionTypes}
name={FilterKeys.PRESCRIPTION_TYPES}
options={allPrescriptionTypes}
label="Type de prescriptions :"
/>
)}
{selectedTab.id === ResourceType.MEDICATION_ADMINISTRATION && administrationRoutes && (
<AdministrationTypesFilter
<MultiSelectInput
value={administrationRoutes}
name={FilterKeys.ADMINISTRATION_ROUTES}
allAdministrationTypes={allAdministrationRoutes}
options={allAdministrationRoutes}
label="Voie d'administration :"
/>
)}
<DatesRangeFilter values={[startDate, endDate]} names={[FilterKeys.START_DATE, FilterKeys.END_DATE]} />
Expand All @@ -384,7 +384,7 @@ const MedicationList = ({ deidentified }: MedicationListProps) => {
value={executiveUnits}
name={FilterKeys.EXECUTIVE_UNITS}
/>
<SelectInput
<MultiSelectInput
value={encounterStatus}
name={FilterKeys.ENCOUNTER_STATUS}
options={encounterStatusList}
Expand Down Expand Up @@ -505,7 +505,7 @@ const MedicationList = ({ deidentified }: MedicationListProps) => {
</Grid>
)}
{selectedTab.id === ResourceType.MEDICATION_REQUEST && (
<SelectInput
<MultiSelectInput
label="Type de prescriptions :"
value={selectedSavedFilter?.filterParams.filters.prescriptionTypes || []}
name={FilterKeys.PRESCRIPTION_TYPES}
Expand All @@ -514,11 +514,12 @@ const MedicationList = ({ deidentified }: MedicationListProps) => {
/>
)}
{selectedTab.id === ResourceType.MEDICATION_ADMINISTRATION && (
<AdministrationTypesFilter
<MultiSelectInput
disabled={isReadonlyFilterInfoModal}
value={selectedSavedFilter?.filterParams.filters.administrationRoutes || []}
name={FilterKeys.ADMINISTRATION_ROUTES}
allAdministrationTypes={allAdministrationRoutes}
options={allAdministrationRoutes}
label="Voie d'administration :"
/>
)}
<DatesRangeFilter
Expand All @@ -535,7 +536,7 @@ const MedicationList = ({ deidentified }: MedicationListProps) => {
value={selectedSavedFilter?.filterParams.filters.executiveUnits || []}
name={FilterKeys.EXECUTIVE_UNITS}
/>
<SelectInput
<MultiSelectInput
label="Statut de la visite associée :"
disabled={isReadonlyFilterInfoModal}
value={selectedSavedFilter?.filterParams.filters.encounterStatus || []}
Expand Down
Loading

0 comments on commit 136bf69

Please sign in to comment.