Skip to content

Commit

Permalink
feat: harmonisation textuelle - Ref gestion-de-projet#2371
Browse files Browse the repository at this point in the history
  • Loading branch information
pl-buiquang authored and aetchego committed Oct 10, 2024
1 parent 68551c5 commit b700862
Show file tree
Hide file tree
Showing 110 changed files with 23,154 additions and 4,932 deletions.
22,710 changes: 19,726 additions & 2,984 deletions package-lock.json

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"antlr4": "^4.13.1-patch-1",
"axios": "^1.6.0",
"buffer": "^6.0.3",
"canvas": "^2.11.2",
"client-oauth2": "^4.2.4",
"d3": "^7.8.2",
"d3-cloud": "^1.2.5",
Expand All @@ -41,6 +42,7 @@
"react-router": "^6.9.0",
"react-router-dom": "^6.9.0",
"react-use-websocket": "4.8.1",
"react-window": "^1.8.10",
"redux": "^4.2.1",
"redux-devtools-extension": "^2.13.9",
"redux-logger": "^3.0.6",
Expand All @@ -60,7 +62,7 @@
"build": "vite build",
"serve": "vite preview",
"lint": "eslint --ext .jsx,.js,.ts,.tsx src/",
"test": "vitest",
"test": "vitest",
"coverage": "vitest run --coverage",
"ui": "vitest --ui"
},
Expand Down Expand Up @@ -98,6 +100,7 @@
"@types/react-redux": "^7.1.25",
"@types/react-router": "^5.1.20",
"@types/react-router-dom": "^5.3.3",
"@types/react-window": "^1.8.8",
"@types/redux-logger": "^3.0.9",
"@types/uuid": "^8.3.4",
"@typescript-eslint/eslint-plugin": "^5.57.0",
Expand Down
4 changes: 3 additions & 1 deletion src/__tests__/data/cohortCreation/claimCriteria.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,14 @@ export const completeClaimCriteria: GhmDataType = {
full_path: 'APHP-ASSISTANCE PUBLIQUE AP-HP/H01-GH RCP',
id: '8312016825',
inferior_levels_ids: '8312016826',
label: 'GH RCP',
name: 'GH RCP',
parent_id: '8312002244',
source_value: 'H01',
status: undefined,
subItems: undefined,
type: 'Groupe hospitalier (GH)'
type: 'Groupe hospitalier (GH)',
system: 'nan'
}
]
}
205 changes: 134 additions & 71 deletions src/components/CreationCohort/DataList_Criteria.tsx

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { BlockWrapper } from 'components/ui/Layout'
import { DurationRangeType } from 'types/searchCriterias'
import { CriteriaLabel } from 'components/ui/CriteriaLabel'
import { getOccurenceDateLabel } from 'utils/requestCriterias'
import ExecutiveUnitsInput from 'components/ui/Inputs/ExecutiveUnit'
import ExecutiveUnitsInput from 'components/ui/Inputs/ExecutiveUnits'

type AdvancedInputsProps = {
sourceType: SourceType
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import { ValueSetWithHierarchy } from 'services/aphp/cohortCreation/fetchObserva
import services from 'services/aphp'
import { ObservationDataType } from 'types/requestCriterias'
import { ValueSet } from 'types'
import { Hierarchy } from 'types/hierarchy'
import { Hierarchy, HierarchyElementWithSystem } from 'types/hierarchy'

Check warning on line 33 in src/components/CreationCohort/DiagramView/components/LogicalOperator/components/CriteriaRightPanel/BiologyForm/components/BiologySearch/BiologySearch.tsx

View workflow job for this annotation

GitHub Actions / test

'Hierarchy' is defined but never used

type BiologySearchListItemProps = {
label: string
Expand Down Expand Up @@ -88,7 +88,7 @@ const BiologySearchListItem: React.FC<BiologySearchListItemProps> = (props) => {
type BiologySearchProps = {
isEdition?: boolean
goBack: () => void
onChangeSelectedCriteria: (data: Hierarchy<any, any>[] | undefined | null) => void
onChangeSelectedCriteria: (data: HierarchyElementWithSystem[] | undefined | null) => void
selectedCriteria: ObservationDataType
onConfirm: () => void
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,15 @@ import useStyles from './styles'
import { useAppDispatch, useAppSelector } from 'state'
import { fetchBiology } from 'state/biology'
import { CriteriaItemDataCache, HierarchyTree } from 'types'
import AdvancedInputs from '../../../AdvancedInputs/AdvancedInputs'
import AdvancedInputs from '../../../AdvancedInputs'
import { ObservationDataType, Comparators, SelectedCriteriaType } from 'types/requestCriterias'
import services from 'services/aphp'
import { BlockWrapper } from 'components/ui/Layout'
import OccurenceInput from 'components/ui/Inputs/Occurences'
import { ErrorWrapper } from 'components/ui/Searchbar/styles'
import { HierarchyElementWithSystem } from 'types/hierarchy'
import { SourceType } from 'types/scope'
import { CriteriaLabel } from 'components/ui/CriteriaLabel'

enum Error {
NO_ERROR,
Expand All @@ -38,9 +41,6 @@ enum Error {
MISSING_VALUE_ERROR,
ADVANCED_INPUTS_ERROR
}
import { SourceType } from 'types/scope'
import { Hierarchy } from 'types/hierarchy'
import { CriteriaLabel } from 'components/ui/CriteriaLabel'

type BiologyFormProps = {
isOpen: boolean
Expand Down Expand Up @@ -90,7 +90,7 @@ const BiologyForm: React.FC<BiologyFormProps> = (props) => {
const defaultValuesCode = currentState.code
? currentState.code.map((code) => {
const criteriaCode = criteriaData.data.biologyData
? criteriaData.data.biologyData.find((g: Hierarchy<any, any>) => g.id === code.id)
? criteriaData.data.biologyData.find((g: HierarchyElementWithSystem) => g.id === code.id)
: null
return {
id: code.id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,29 +22,31 @@ import KeyboardBackspaceIcon from '@mui/icons-material/KeyboardBackspace'

import { useAppDispatch, useAppSelector } from 'state'

import {
checkIfIndeterminated,
expandItem,
findEquivalentRowInItemAndSubItems,
getHierarchySelection
} from 'utils/pmsi'
import { expandItem, findEquivalentRowInItemAndSubItems, getHierarchySelection } from 'utils/pmsi'

import useStyles from './styles'
import { decrementLoadingSyncHierarchyTable, incrementLoadingSyncHierarchyTable } from 'state/syncHierarchyTable'
import { findSelectedInListAndSubItems } from 'utils/cohortCreation'
import { defaultBiology } from '../../index'
import { HierarchyTree } from 'types'
import { Hierarchy } from 'types/hierarchy'
import { HierarchyElementWithSystem } from 'types/hierarchy'

type BiologyListItemProps = {
biologyItem: Hierarchy<any, any>
selectedItems?: Hierarchy<any, any>[] | null
handleClick: (biologyItem: Hierarchy<any, any>[] | null | undefined, newHierarchy?: Hierarchy<any, any>[]) => void
biologyItem: HierarchyElementWithSystem
selectedItems?: HierarchyElementWithSystem[] | null
handleClick: (
biologyItem: HierarchyElementWithSystem[] | null | undefined,
newHierarchy?: HierarchyElementWithSystem[]
) => void
}

const BiologyListItem: React.FC<BiologyListItemProps> = (props) => {
const { biologyItem, selectedItems, handleClick } = props
const { id, label, subItems } = biologyItem
const {
id,

Check warning on line 46 in src/components/CreationCohort/DiagramView/components/LogicalOperator/components/CriteriaRightPanel/BiologyForm/components/Hierarchy/BiologyHierarchy.tsx

View workflow job for this annotation

GitHub Actions / test

'id' is assigned a value but never used
id: { label },
subItems
} = biologyItem

const { classes, cx } = useStyles()
const dispatch = useAppDispatch()
Expand All @@ -55,7 +57,7 @@ const BiologyListItem: React.FC<BiologyListItemProps> = (props) => {

const [open, setOpen] = useState(false)
const isSelected = findSelectedInListAndSubItems(selectedItems ?? [], biologyItem, biologyHierarchy)
const isIndeterminated = checkIfIndeterminated(biologyItem, selectedItems)
// const isIndeterminated = checkIfIndeterminated(biologyItem, selectedItems)
const _onExpand = async (biologyCode: string) => {
if (isLoadingsyncHierarchyTable > 0 || isLoadingPmsi > 0) return
dispatch(incrementLoadingSyncHierarchyTable())
Expand All @@ -71,7 +73,7 @@ const BiologyListItem: React.FC<BiologyListItemProps> = (props) => {
dispatch(decrementLoadingSyncHierarchyTable())
}

const handleClickOnHierarchy = async (biologyItem: Hierarchy<any, any>) => {
const handleClickOnHierarchy = async (biologyItem: HierarchyElementWithSystem) => {
if (isLoadingsyncHierarchyTable > 0 || isLoadingPmsi > 0) return
dispatch(incrementLoadingSyncHierarchyTable())
const newSelectedItems = getHierarchySelection(biologyItem, selectedItems || [], biologyHierarchy)
Expand All @@ -87,7 +89,7 @@ const BiologyListItem: React.FC<BiologyListItemProps> = (props) => {
onClick={() => handleClickOnHierarchy(biologyItem)}
className={cx(classes.indicator, {
[classes.selectedIndicator]: isSelected,
[classes.indeterminateIndicator]: isIndeterminated
[classes.indeterminateIndicator]: /*isIndeterminated*/ false
})}
style={{ color: '#0063af', cursor: 'pointer' }}
/>
Expand All @@ -107,21 +109,21 @@ const BiologyListItem: React.FC<BiologyListItemProps> = (props) => {
onClick={() => handleClickOnHierarchy(biologyItem)}
className={cx(classes.indicator, {
[classes.selectedIndicator]: isSelected,
[classes.indeterminateIndicator]: isIndeterminated
[classes.indeterminateIndicator]: /*isIndeterminated*/ false
})}
style={{ color: '#0063af', cursor: 'pointer' }}
/>
</ListItemIcon>
<Tooltip title={label} enterDelay={2500}>
<ListItemText onClick={() => _onExpand(id)} className={classes.label} primary={label} />
<ListItemText onClick={() => _onExpand(label)} className={classes.label} primary={label} />
</Tooltip>
{id !== '*' &&
(open ? <ExpandLess onClick={() => setOpen(!open)} /> : <ExpandMore onClick={() => _onExpand(id)} />)}
{label !== '*' &&
(open ? <ExpandLess onClick={() => setOpen(!open)} /> : <ExpandMore onClick={() => _onExpand(label)} />)}
</ListItem>
<Collapse in={id === '*' ? true : open} timeout="auto" unmountOnExit>
<Collapse in={label === '*' ? true : open} timeout="auto" unmountOnExit>
<List component="div" disablePadding className={classes.subItemsContainer}>
<div className={classes.subItemsContainerIndicator} />
{subItems?.map((biologyHierarchySubItem: Hierarchy<any, any>, index: number) =>
{subItems?.map((biologyHierarchySubItem: HierarchyElementWithSystem, index: number) =>
biologyHierarchySubItem.id === 'loading' ? (
<Fragment key={index + biologyHierarchySubItem.id}>
<div className={classes.subItemsIndicator} />
Expand Down Expand Up @@ -150,8 +152,8 @@ type BiologyHierarchyProps = {
selectedCriteria: any
goBack: () => void
onChangeSelectedHierarchy: (
data: Hierarchy<any, any>[] | null | undefined,
newHierarchy?: Hierarchy<any, any>[]
data: HierarchyElementWithSystem[] | null | undefined,
newHierarchy?: HierarchyElementWithSystem[]
) => void
isEdition?: boolean
onConfirm: () => void
Expand All @@ -175,14 +177,14 @@ const BiologyHierarchy: React.FC<BiologyHierarchyProps> = (props) => {
newList.code = selectedCriteria.code
}
newList.code.map(
(item: Hierarchy<any, any>) => findEquivalentRowInItemAndSubItems(item, biologyHierarchy).equivalentRow
(item: HierarchyElementWithSystem) => findEquivalentRowInItemAndSubItems(item, biologyHierarchy).equivalentRow
)
setCurrentState(newList)
}, [initialState, biologyHierarchy, selectedCriteria])

const _handleClick = (
newSelectedItems: Hierarchy<any, any>[] | null | undefined,
newHierarchy?: Hierarchy<any, any>[]
newSelectedItems: HierarchyElementWithSystem[] | null | undefined,
newHierarchy?: HierarchyElementWithSystem[]
) => {
onChangeSelectedHierarchy(newSelectedItems, newHierarchy)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import { fetchBiology } from 'state/biology'
import { useAppDispatch, useAppSelector } from 'state'
import { Comparators, ObservationDataType, CriteriaType } from 'types/requestCriterias'
import { CriteriaDrawerComponentProps } from 'types'
import { Hierarchy } from 'types/hierarchy'
import { AppConfig } from 'config'
import { HierarchyElementWithSystem } from 'types/hierarchy'

export const defaultBiology: Omit<ObservationDataType, 'id'> = {
type: CriteriaType.OBSERVATION,
Expand Down Expand Up @@ -46,13 +46,17 @@ const Index = (props: CriteriaDrawerComponentProps) => {
const biologyHierarchy = useAppSelector((state) => state.biology.list || {})

const _onChangeSelectedHierarchy = (
newSelectedItems: Hierarchy<any, any>[] | null | undefined,
newHierarchy?: Hierarchy<any, any>[]
newSelectedItems: HierarchyElementWithSystem[] | null | undefined,
newHierarchy?: HierarchyElementWithSystem[]
) => {
_onChangeFormValue('code', newSelectedItems, newHierarchy)
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const _onChangeFormValue = async (key: string, value: any, newHierarchy: Hierarchy<any, any>[] = biologyHierarchy) =>
const _onChangeFormValue = async (
key: string,
value: any,

Check warning on line 57 in src/components/CreationCohort/DiagramView/components/LogicalOperator/components/CriteriaRightPanel/BiologyForm/index.tsx

View workflow job for this annotation

GitHub Actions / test

Unexpected any. Specify a different type
newHierarchy: HierarchyElementWithSystem[] = biologyHierarchy
) =>
await syncOnChangeFormValue(
key,
value,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {

import KeyboardBackspaceIcon from '@mui/icons-material/KeyboardBackspace'

import AdvancedInputs from 'components/CreationCohort/DiagramView/components/LogicalOperator/components/CriteriaRightPanel/AdvancedInputs/AdvancedInputs'
import AdvancedInputs from 'components/CreationCohort/DiagramView/components/LogicalOperator/components/CriteriaRightPanel/AdvancedInputs'

import useStyles from './styles'
import { useAppDispatch, useAppSelector } from 'state'
Expand All @@ -30,7 +30,7 @@ import { CcamDataType, Comparators, SelectedCriteriaType } from 'types/requestCr
import { BlockWrapper } from 'components/ui/Layout'
import OccurenceInput from 'components/ui/Inputs/Occurences'
import { SourceType } from 'types/scope'
import { Hierarchy } from 'types/hierarchy'
import { Hierarchy, HierarchyElementWithSystem } from 'types/hierarchy'

Check warning on line 33 in src/components/CreationCohort/DiagramView/components/LogicalOperator/components/CriteriaRightPanel/CCAM/components/Form/CCAMForm.tsx

View workflow job for this annotation

GitHub Actions / test

'Hierarchy' is defined but never used

type CcamFormProps = {
isOpen: boolean
Expand Down Expand Up @@ -70,13 +70,13 @@ const CcamForm: React.FC<CcamFormProps> = (props) => {
const getCCAMOptions = async (searchValue: string, signal: AbortSignal) => {
const ccamOptions = await services.cohortCreation.fetchCcamData(searchValue, false, signal)

return ccamOptions && ccamOptions.length > 0 ? ccamOptions : []
return ccamOptions && (ccamOptions.results || []).length > 0 ? ccamOptions : []
}

const defaultValuesCode = currentState.code
? currentState.code.map((code) => {
const criteriaCode = criteriaData.data.ccamData
? criteriaData.data.ccamData.find((g: Hierarchy<any, any>) => g.id === code.id)
? criteriaData.data.ccamData.find((g: HierarchyElementWithSystem) => g.id === code.id)
: null
return {
id: code.id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,15 @@ import { findSelectedInListAndSubItems } from 'utils/cohortCreation'
import { defaultProcedure } from '../../index'
import { HierarchyTree } from 'types'
import { CcamDataType } from 'types/requestCriterias'
import { Hierarchy } from 'types/hierarchy'
import { Hierarchy, HierarchyElementWithSystem } from 'types/hierarchy'

type ProcedureListItemProps = {
procedureItem: Hierarchy<any, any>
selectedItems?: Hierarchy<any, any>[] | null
handleClick: (procedureItem: Hierarchy<any, any>[] | null | undefined, newHierarchy?: Hierarchy<any, any>[]) => void
procedureItem: HierarchyElementWithSystem
selectedItems?: HierarchyElementWithSystem[] | null
handleClick: (
procedureItem: HierarchyElementWithSystem[] | null | undefined,
newHierarchy?: HierarchyElementWithSystem[]
) => void
}

const ProcedureListItem: React.FC<ProcedureListItemProps> = (props) => {
Expand Down Expand Up @@ -72,7 +75,7 @@ const ProcedureListItem: React.FC<ProcedureListItemProps> = (props) => {
dispatch(decrementLoadingSyncHierarchyTable())
}

const handleClickOnHierarchy = (procedureItem: Hierarchy<any, any>) => {
const handleClickOnHierarchy = async (procedureItem: HierarchyElementWithSystem) => {
if (isLoadingsyncHierarchyTable > 0 || isLoadingPmsi > 0) return
dispatch(incrementLoadingSyncHierarchyTable())
const newSelectedItems = getHierarchySelection(procedureItem, selectedItems || [], procedureHierarchy)
Expand Down Expand Up @@ -150,8 +153,8 @@ type ProcedureHierarchyProps = {
selectedCriteria: CcamDataType
goBack: () => void
onChangeSelectedHierarchy: (
data: Hierarchy<any, any>[] | null | undefined,
newHierarchy?: Hierarchy<any, any>[]
data: HierarchyElementWithSystem[] | null | undefined,
newHierarchy?: HierarchyElementWithSystem[]
) => void
isEdition?: boolean
onConfirm: () => void
Expand All @@ -175,14 +178,14 @@ const ProcedureHierarchy: React.FC<ProcedureHierarchyProps> = (props) => {
newList.code = selectedCriteria.code
}
newList.code?.map(
(item: Hierarchy<any, any>) => findEquivalentRowInItemAndSubItems(item, ccamHierarchy).equivalentRow
(item: HierarchyElementWithSystem) => findEquivalentRowInItemAndSubItems(item, ccamHierarchy).equivalentRow
)
setCurrentState(newList)
}, [initialState, ccamHierarchy, selectedCriteria])

const _handleClick = (
newSelectedItems: Hierarchy<any, any>[] | null | undefined,
newHierarchy?: Hierarchy<any, any>[]
newSelectedItems: HierarchyElementWithSystem[] | null | undefined,
newHierarchy?: HierarchyElementWithSystem[]
) => {
onChangeSelectedHierarchy(newSelectedItems, newHierarchy)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { EXPLORATION } from '../../../../../../../..//constants'

import { CriteriaDrawerComponentProps } from 'types'
import { CcamDataType, Comparators, CriteriaType } from 'types/requestCriterias'
import { Hierarchy } from 'types/hierarchy'
import { HierarchyElementWithSystem } from 'types/hierarchy'

export const defaultProcedure: Omit<CcamDataType, 'id'> = {
type: CriteriaType.PROCEDURE,
Expand Down Expand Up @@ -43,13 +43,17 @@ const Index = (props: CriteriaDrawerComponentProps) => {
const { classes } = useStyles()

const _onChangeSelectedHierarchy = (
newSelectedItems: Hierarchy<any, any>[] | null | undefined,
newHierarchy?: Hierarchy<any, any>[]
newSelectedItems: HierarchyElementWithSystem[] | null | undefined,
newHierarchy?: HierarchyElementWithSystem[]
) => {
_onChangeFormValue('code', newSelectedItems, newHierarchy)
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const _onChangeFormValue = async (key: string, value: any, newHierarchy: Hierarchy<any, any>[] = ccamHierarchy) =>
const _onChangeFormValue = async (
key: string,
value: any,
newHierarchy: HierarchyElementWithSystem[] = ccamHierarchy
) =>
await syncOnChangeFormValue(
key,
value,
Expand Down
Loading

0 comments on commit b700862

Please sign in to comment.