Skip to content

Commit

Permalink
correction linter
Browse files Browse the repository at this point in the history
  • Loading branch information
aetchego committed Nov 25, 2024
1 parent af54c1b commit 9b463c5
Show file tree
Hide file tree
Showing 24 changed files with 41 additions and 72 deletions.
6 changes: 3 additions & 3 deletions src/components/CreationCohort/DataList_Criteria.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@ import HospitForm from './DiagramView/components/LogicalOperator/components/Crit
import { CriteriaType, CriteriaTypeLabels } from 'types/requestCriterias'
import { getConfig } from 'config'
import { getChildrenFromCodes, getCodeList } from 'services/aphp/serviceValueSets'
import { Hierarchy } from 'types/hierarchy'

import docTypes from 'assets/docTypes.json'
import { birthStatusData, booleanFieldsData, booleanOpenChoiceFieldsData, vmeData } from 'data/questionnaire_data'
import { VitalStatusLabel } from 'types/searchCriterias'
import { FhirItem } from 'types/valueSet'
import { Hierarchy } from 'types/hierarchy'

const async = (fetch: () => Promise<Back_API_Response<FhirItem>>) => async () => (await fetch()).results

Expand Down Expand Up @@ -158,9 +159,8 @@ const criteriaList: () => CriteriaItemType[] = () => {
} catch (e) {
results = (await getChildrenFromCodes(getConfig().features.medication.valueSets.medicationAtc.url, [code]))
.results
} finally {
return results
}
return results
},
prescriptionTypes: async(() =>
getCodeList(getConfig().features.medication.valueSets.medicationPrescriptionTypes.url)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import KeyboardBackspaceIcon from '@mui/icons-material/KeyboardBackspace'
import useStyles from '../formStyles'
import { CriteriaDrawerComponentProps } from 'types'
import { Cim10DataType, Comparators, CriteriaType } from 'types/requestCriterias'
import { Hierarchy } from 'types/hierarchy'
import { BlockWrapper } from 'components/ui/Layout'
import OccurenceInput from 'components/ui/Inputs/Occurences'
import AdvancedInputs from '../AdvancedInputs'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,7 @@ const HospitForm = ({
const [encounterStatus, setEncounterStatus] = useState<LabelObject[]>(
mappingCriteria(criteria?.encounterStatus, CriteriaDataKey.ENCOUNTER_STATUS, criteriaData) || []
)
const [encounterService, setEncounterService] = useState<Hierarchy<ScopeElement>[]>(
criteria?.encounterService || []
)
const [encounterService, setEncounterService] = useState<Hierarchy<ScopeElement>[]>(criteria?.encounterService || [])
const [occurrence, setOccurrence] = useState<number>(criteria?.occurrence || 1)
const [occurrenceComparator, setOccurrenceComparator] = useState<Comparators>(
criteria?.occurrenceComparator || Comparators.GREATER_OR_EQUAL
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import {
DurationRangeType,
LabelObject
} from 'types/searchCriterias'
import useStyles from './styles'
import { mappingCriteria } from '../DemographicForm'
import SearchbarWithCheck from 'components/ui/Inputs/SearchbarWithCheck'
import UidTextfield from 'components/ui/Inputs/UidTextfield'
Expand Down Expand Up @@ -50,7 +49,6 @@ export const withDocumentOptions = [
]

const ImagingForm: React.FC<CriteriaDrawerComponentProps> = (props) => {

Check warning on line 51 in src/components/CreationCohort/DiagramView/components/LogicalOperator/components/CriteriaRightPanel/ImagingForm/index.tsx

View workflow job for this annotation

GitHub Actions / test

Arrow function has too many statements (37). Maximum allowed is 30
const { classes } = useStyles()
const appConfig = useContext(AppConfig)
const { criteriaData, onChangeSelectedCriteria, goBack } = props
const selectedCriteria = props.selectedCriteria as ImagingDataType
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,7 @@ const PregnantForm = ({
const [ultrasoundMonitoring, setUltrasoundMonitoring] = useState<LabelObject[]>(
mappingCriteria(criteria?.ultrasoundMonitoring, CriteriaDataKey.ULTRASOUND_MONITORING, criteriaData) || []
)
const [encounterService, setEncounterService] = useState<Hierarchy<ScopeElement>[]>(
criteria?.encounterService || []
)
const [encounterService, setEncounterService] = useState<Hierarchy<ScopeElement>[]>(criteria?.encounterService || [])
const [occurrence, setOccurrence] = useState<number>(criteria?.occurrence || 1)
const [occurrenceComparator, setOccurrenceComparator] = useState<Comparators>(
criteria?.occurrenceComparator || Comparators.GREATER_OR_EQUAL
Expand Down
1 change: 0 additions & 1 deletion src/components/CreationCohort/DiagramView/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import PopulationCard from './components/PopulationCard/PopulationCard'
import ModalRightError from './components/PopulationCard/components/ModalRightError'
import { checkNominativeCriteria, cleanNominativeCriterias } from 'utils/cohortCreation'
import ScopeTree from 'components/ScopeTree'
import { LabelObject } from 'types/searchCriterias'

const DiagramView = () => {
const dispatch = useAppDispatch()
Expand Down
2 changes: 1 addition & 1 deletion src/components/Dashboard/PatientList/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useState, useEffect, useRef, useMemo } from 'react'

import { CircularProgress, Grid, Tooltip, Typography } from '@mui/material'
import { CircularProgress, Grid, Tooltip } from '@mui/material'

import DataTablePatient from 'components/DataTable/DataTablePatient'

Expand Down
2 changes: 1 addition & 1 deletion src/components/Hierarchy/CodesWithSystems.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const CodesWithSystems = <T,>({
{codes.length > 0 && isExtended && (
<Grid container alignItems="center" overflow="hidden">
{groupedBySystem.map((group) => (
<Grid item xs={12}>
<Grid item xs={12} key={group.system}>
{isDisplayedWithSystem(group.system) && (
<Typography fontWeight="700" marginRight="5px" padding={'8px 0'}>
{`${getLabelFromSystem(group.system)} (${group.codes.length})`}
Expand Down
4 changes: 0 additions & 4 deletions src/components/Patient/PatientMedication/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,6 @@ import { getCodeList } from 'services/aphp/serviceValueSets'
import { getValueSetsFromSystems } from 'utils/valueSets'
import CodeFilter from 'components/Filters/CodeFilter'

type PatientMedicationProps = {
groupId?: string
}

type MedicationSearchResults = {
deidentified: boolean
list: MedicationRequest[] | MedicationAdministration[]
Expand Down
2 changes: 1 addition & 1 deletion src/components/SearchValueSet/ValueSetTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
Typography
} from '@mui/material'
import { LoadingStatus, SelectedStatus } from 'types'
import { Hierarchy, HierarchyInfo, Mode, SearchMode } from 'types/hierarchy'
import { Hierarchy, HierarchyInfo, SearchMode } from 'types/hierarchy'
import { KeyboardArrowDown, KeyboardArrowRight, IndeterminateCheckBoxOutlined } from '@mui/icons-material'
import { CellWrapper, RowContainerWrapper, RowWrapper } from '../Hierarchy/styles'
import { sortArray } from 'utils/arrays'
Expand Down
2 changes: 1 addition & 1 deletion src/components/SearchValueSet/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import SelectedCodes from 'components/Hierarchy/SelectedCodes'
import { useSearchValueSet } from 'hooks/valueSet/useSearchValueSet'
import { Displayer } from 'components/ui/Displayer/styles'
import ClearIcon from '@mui/icons-material/Clear'
import { Hierarchy, SearchMode, SearchModeLabel } from 'types/hierarchy'
import { Hierarchy, SearchMode, SearchModeLabel } from 'types/hierarchy'
import { cleanNode } from 'utils/hierarchy/hierarchy'

type SearchValueSetProps = {
Expand Down
2 changes: 1 addition & 1 deletion src/components/ui/Layout/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ type CustomProps = {
export const BlockWrapper = styled(Grid)<CustomProps>(({ padding = 0, margin = 0 }) => ({
padding: typeof padding === 'string' ? padding : `${padding}px`,
margin: typeof margin === 'string' ? margin : `${margin}px`
}))
}))
2 changes: 1 addition & 1 deletion src/hooks/hierarchy/useHierarchy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export const useHierarchy = <T>(
) => {
const newTrees: Map<string, Hierarchy<T>[]> = new Map()
const newHierarchies: Map<string, HierarchyInfo<T>> = new Map()
let allCodes: Codes<Hierarchy<T>> = new Map()
const allCodes: Codes<Hierarchy<T>> = new Map()
for (const handler of initHandlers) {
const { results: baseTree, count } = await handler.fetchBaseTree()
const currentSelected = selectedCodes.get(handler.system) || new Map()
Expand Down
16 changes: 8 additions & 8 deletions src/hooks/search/useSearchParameters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,21 @@ import { Reference } from 'types/valueSet'
export const LIMIT_PER_PAGE = 20

export type SearchParameters = {
searchInput?: string,
searchMode?: boolean,
page?: number,
limit?: number,
count?: number,
totalPages?: number,
references?: Reference[],
searchInput?: string
searchMode?: boolean
page?: number
limit?: number
count?: number
totalPages?: number
references?: Reference[]
tabs?: TabType[]
}

export const useSearchParameters = () => {
const [searchInput, setSearchInput] = useState('')
const [searchMode, setSearchMode] = useState(false)
const [page, setPage] = useState(0)
const [limit, setLimit] = useState(LIMIT_PER_PAGE)
const [limit, setLimit] = useState(LIMIT_PER_PAGE)
const [count, setCount] = useState(0)
const [totalPages, setTotalPages] = useState(0)
const [references, setReferences] = useState<Reference[]>([])
Expand Down
6 changes: 3 additions & 3 deletions src/services/aphp/serviceValueSets.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Extension, ValueSet, ValueSetComposeIncludeConcept, ValueSetExpansion } from 'fhir/r4'
import apiFhir from 'services/apiFhir'
import { Back_API_Response, FHIR_API_Response, FHIR_Bundle_Response } from 'types'
import { Hierarchy } from 'types/hierarchy'
import { Hierarchy } from 'types/hierarchy'
import { getApiResponseResourceOrThrow, getApiResponseResourcesOrThrow } from 'utils/apiHelpers'
import { capitalizeFirstLetter } from 'utils/capitalize'
import { getConfig } from 'config'
Expand Down Expand Up @@ -238,7 +238,7 @@ export const getHierarchyRoots = async (
const chapters = codeList
.filter((code) => filterRoots(code))
.map((e) => mapFhirHierarchyToHierarchyWithLabelAndSystem(e))
let toBeAdoptedCodes = codeList
const toBeAdoptedCodes = codeList
.filter((code) => !filterRoots(code))
.map((e) => mapFhirHierarchyToHierarchyWithLabelAndSystem(e))
const childrenIds = chapters.map((code) => code.id)
Expand All @@ -260,7 +260,7 @@ export const getHierarchyRoots = async (
childrenIds.push(UNKOWN_HIERARCHY_CHAPTER)
subItems = [...chaptersEntities, unknownChapter]
}
let results = [
const results = [
{
id: HIERARCHY_ROOT,
label: valueSetTitle,
Expand Down
6 changes: 2 additions & 4 deletions src/state/patient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ const fetchPmsi = createAsyncThunk<FetchPmsiReturn, FetchPmsiParams, { state: Ro
const sortDirection = options.searchCriterias.orderBy.orderDirection
const page = options.page ?? 1
const searchInput = options.searchCriterias.searchInput === '' ? '' : options.searchCriterias.searchInput
const code = options.searchCriterias.filters.code.map((e) => encodeURIComponent(`${e.system}|${e.id}`)).join(',')
const code = options.searchCriterias.filters.code.map((e) => encodeURIComponent(`${e.system}|${e.id}`)).join(',')
const source = options.searchCriterias.filters.source ?? ''
const diagnosticTypes = options.searchCriterias.filters.diagnosticTypes?.map((type) => type.id) ?? []
const nda = options.searchCriterias.filters.nda
Expand Down Expand Up @@ -227,9 +227,7 @@ const fetchBiology = createAsyncThunk<FetchBiologyReturn, FetchBiologyParams, {
const sortDirection = searchCriterias.orderBy.orderDirection
const searchInput = searchCriterias.searchInput
const nda = searchCriterias.filters.nda
const code = options.searchCriterias.filters.code
.map((e) => encodeURIComponent(`${e.system}|${e.id}`))
.join(',')
const code = options.searchCriterias.filters.code.map((e) => encodeURIComponent(`${e.system}|${e.id}`)).join(',')
const startDate = searchCriterias.filters.startDate
const endDate = searchCriterias.filters.endDate
const executiveUnits = searchCriterias.filters.executiveUnits.map((unit) => unit.id)
Expand Down
1 change: 0 additions & 1 deletion src/state/valueSets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { RootState } from 'state'
import { mapCacheToCodes } from 'utils/hierarchy/hierarchy'
import { FhirItem } from 'types/valueSet'


const valueSetsAdapter = createEntityAdapter<CodesCache<FhirItem>>()

const valueSetsSlice = createSlice({
Expand Down
2 changes: 1 addition & 1 deletion src/types/requestCriterias.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ScopeElement, SimpleCodeType } from 'types'
import { Hierarchy } from './hierarchy'
import { Hierarchy } from './hierarchy'
import { DocumentAttachmentMethod, DurationRangeType, LabelObject, SearchByTypes } from './searchCriterias'
import { FhirItem } from './valueSet'

Expand Down
4 changes: 2 additions & 2 deletions src/types/scope.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@ export enum Rights {
}

export enum System {
ScopeTree = "scope_tree"
}
ScopeTree = 'scope_tree'
}
5 changes: 1 addition & 4 deletions src/utils/cohortCreation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2117,10 +2117,7 @@ export const getDataFromFetch = async (
const prevData = prevDataCache[dataKey]?.find((data: any) => data.id === code?.id)
const codeData = prevData ? [prevData] : await _criterion.fetch[dataKey]?.(code?.id, true)
const existingCodes = criteriaDataCache.data[dataKey] || []
criteriaDataCache.data[dataKey] = [
...existingCodes,
...((codeData as Hierarchy<FhirItem>[]) || [])
]
criteriaDataCache.data[dataKey] = [...existingCodes, ...((codeData as Hierarchy<FhirItem>[]) || [])]
}
}
}
Expand Down
24 changes: 7 additions & 17 deletions src/utils/hierarchy/hierarchy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export const getMissingCodesWithSystems = async <T>(
codes: Codes<Hierarchy<T>>,
fetchHandler: (ids: string, system: string) => Promise<Hierarchy<T, string>[]>
) => {
let allCodes: Codes<Hierarchy<T>> = new Map(codes)
const allCodes: Codes<Hierarchy<T>> = new Map(codes)
for (const group of groupBySystem) {
const tree = trees.get(group.system) || []
const codesBySystem = codes.get(group.system) || new Map()
Expand Down Expand Up @@ -184,7 +184,7 @@ export const buildTree = <T>(
if (nextPath.size) {
if (!node.subItems) node.subItems = getMissingSubItems(node, codes)
for (const [nextKey, nextValue] of nextPath) {
let index = node.subItems.findIndex((elem) => elem.id === nextKey)
const index = node.subItems.findIndex((elem) => elem.id === nextKey)
if (index > -1) {
const item = buildBranch(node.subItems[index], system, [nextKey, nextValue], codes, selected, mode)
node.subItems[index] = item
Expand All @@ -203,7 +203,7 @@ export const buildTree = <T>(
}
return node
}
const paths = getPaths(baseTree, endCodes, mode === Mode.UNSELECT_ALL || mode === Mode.SELECT_ALL)
const paths = getPaths(baseTree, endCodes)
let uniquePaths = getUniquePath(paths)
if (mode === Mode.SELECT || mode === Mode.UNSELECT) uniquePaths = getPathsForSelection(uniquePaths, endCodes)
if (mode === Mode.INIT) baseTree = []
Expand Down Expand Up @@ -248,7 +248,7 @@ export const getDisplayFromTrees = <T>(
toDisplay: Hierarchy<T, string>[],
trees: Map<string, Hierarchy<T, string>[]>
) => {
let branches: Hierarchy<T, string>[] = []
const branches: Hierarchy<T, string>[] = []
toDisplay.forEach((node) => {
const currentTree = trees.get(node.system)
if (currentTree) {
Expand All @@ -274,20 +274,10 @@ const findBranch = <T>(path: string[], tree: Hierarchy<T, string>[]): Hierarchy<
return branch
}

const getPaths = <T>(baseTree: Hierarchy<T, string>[], endCodes: Hierarchy<T, string>[], selectAll: boolean) => {
let paths = endCodes.map((item) =>
const getPaths = <T>(baseTree: Hierarchy<T, string>[], endCodes: Hierarchy<T, string>[]) => {
const paths = endCodes.map((item) =>
item.above_levels_ids ? [...getAboveLevelsWithRights(item, baseTree), ...[item.id]] : [item.id]
)
/*if (selectAll) {
for (const path of paths) {
const lastId = path[path.length - 1]
paths = paths.filter((path) => {
const index = path.findIndex((id) => id === lastId)
if (index < 0 || index === path.length - 1) return true
return false
})
}
}*/
return paths
}

Expand All @@ -307,7 +297,7 @@ const getUniquePath = (paths: string[][]): InfiniteMap => {

const getPathsForSelection = <T>(paths: InfiniteMap, endCodes: Hierarchy<T>[]): InfiniteMap => {
const codesMap = mapHierarchyToMap(endCodes)
for (let [key, values] of paths) {
for (const [key, values] of paths) {
if (codesMap.get(key)) paths.set(key, new Map())
else getPathsForSelection(values, endCodes)
}
Expand Down
2 changes: 1 addition & 1 deletion src/utils/map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ export const replaceInMap = <K, V>(id: K, value: V, map: Map<K, V>) => {
const newMap = new Map(map)
newMap.set(id, value)
return newMap
}
}
7 changes: 2 additions & 5 deletions src/utils/mappers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,10 @@ export const buildLabelObjectFilter = (criterion: LabelObject[] | undefined | nu
}

export const unbuildLabelObjectFilter = (currentCriterion: any, filterName: string, values?: string | null) => {
console.log("test unbuild")
const valuesIds = values?.split(',') || []

const newArray = valuesIds?.map((value) => (/*value.includes('|*') ? { id: '*' } : */{ id: value }))
if (newArray) {
const newArray = valuesIds?.map((value) => /*value.includes('|*') ? { id: '*' } : */ ({ id: value }))
if (newArray)
currentCriterion[filterName] = currentCriterion ? [...currentCriterion[filterName], ...newArray] : newArray
}
}

export const buildEncounterServiceFilter = (criterion?: LabelObject[]) => {
Expand Down
6 changes: 3 additions & 3 deletions src/utils/valueSets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,17 @@ export const getLabelFromCode = <T>(code: Hierarchy<T>) => {
return code.label
}

export const getFullLabelFromCode = <T>(code: LabelObject) => {
export const getFullLabelFromCode = (code: LabelObject) => {
let label = ''
if (code.system) {
if (isDisplayedWithSystem(code.system)) label+= `${getLabelFromSystem(code.system)} - `
if (isDisplayedWithSystem(code.system)) label += `${getLabelFromSystem(code.system)} - `
if (isDisplayedWithCode(code.system) && code.id !== HIERARCHY_ROOT) label += `${code.id} - `
}
label += code.label
return label
}

export const getLabelFromSystem = <T>(system: string) => {
export const getLabelFromSystem = (system: string) => {
const isFound = getValueSetsFromSystems([system])?.[0]
return isFound?.label || ''
}

0 comments on commit 9b463c5

Please sign in to comment.