Skip to content

Commit

Permalink
feat: add executive unit component - Ref gestion-de-projet#1603
Browse files Browse the repository at this point in the history
  • Loading branch information
mourads committed May 18, 2023
1 parent 2517073 commit b962d3d
Show file tree
Hide file tree
Showing 16 changed files with 475 additions and 117 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { Fragment, useState, useEffect, useRef } from 'react'
import React, { Fragment, useEffect, useRef, useState } from 'react'
import moment from 'moment'

import Chip from '@mui/material/Chip'
Expand All @@ -10,11 +10,12 @@ import KeyboardArrowUpIcon from '@mui/icons-material/KeyboardArrowUp'
import KeyboardArrowDownIcon from '@mui/icons-material/KeyboardArrowDown'

import { useAppSelector } from 'state'
import { DocType, SearchByTypes, SelectedCriteriaType } from 'types'
import { DocType, ScopeTreeRow, SearchByTypes, SelectedCriteriaType } from 'types'

import docTypes from 'assets/docTypes.json'

import useStyles from './styles'
import { RESSOURCE_TYPE_PATIENT } from 'utils/cohortCreation'

type CriteriaCardContentProps = {
currentCriteria: SelectedCriteriaType
Expand Down Expand Up @@ -917,6 +918,29 @@ const CriteriaCardContent: React.FC<CriteriaCardContentProps> = ({ currentCriter
)
]
}
const displaySelectedExecutiveUnits = (hospitalList: ScopeTreeRow[], tooltip?: boolean) => {
return hospitalList && hospitalList.length > 0
? hospitalList.map((item) => item.name).reduce(tooltip ? tooltipReducer : reducer)
: ''
}

if (_currentCriteria.type !== RESSOURCE_TYPE_PATIENT) {
content = [
...content,
_currentCriteria && _currentCriteria?.encounterService && _currentCriteria?.encounterService.length > 0 && (
<Chip
className={classes.criteriaChip}
label={
<Tooltip title={displaySelectedExecutiveUnits(_currentCriteria?.encounterService)}>
<Typography style={{ maxWidth: 500 }} noWrap>
{displaySelectedExecutiveUnits(_currentCriteria?.encounterService)}
</Typography>
</Tooltip>
}
/>
)
]
}

content = content.filter((c) => c) // Filter null element
return content
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const useStyles = makeStyles((theme: Theme) => ({
padding: 8,
marginTop: 12,
minWidth: 400,
maxWidth: 800,
maxWidth: 850,
position: 'relative',
'&::before': {
width: 38,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import React, { useState } from 'react'

import { Collapse, Typography, Grid, IconButton } from '@mui/material'
import { Collapse, Grid, IconButton, Typography } from '@mui/material'

import KeyboardArrowUpIcon from '@mui/icons-material/KeyboardArrowUp'
import KeyboardArrowDownIcon from '@mui/icons-material/KeyboardArrowDown'

import OccurrencesInputs from './OccurrencesInputs/OccurrencesInputs'
import VisitInputs from './VisitInputs/VisitInputs'
import PopulationCard from '../../../../PopulationCard/PopulationCard'
import { UNITE_EXECUTRICE } from 'utils/cohortCreation'
import { ScopeTreeRow } from 'types'

type AdvancedInputsProps = {
form: 'cim10' | 'ccam' | 'ghm' | 'document' | 'medication' | 'biology'
Expand All @@ -26,6 +29,10 @@ const AdvancedInputs: React.FC<AdvancedInputsProps> = (props) => {

const [checked, setCheck] = useState(optionsIsUsed)

const _onSubmitExecutiveUnits = (_selectedExecutiveUnits: ScopeTreeRow[] | undefined) => {
onChangeValue('encounterService', _selectedExecutiveUnits)
}

return (
<Grid container direction="column">
<Grid
Expand All @@ -46,6 +53,18 @@ const AdvancedInputs: React.FC<AdvancedInputsProps> = (props) => {
</Grid>

<Collapse in={checked} unmountOnExit>
<Grid item container direction="row" alignItems="center" style={{ padding: '1em' }}>
<PopulationCard
form={form}
label={UNITE_EXECUTRICE}
title={UNITE_EXECUTRICE}
executiveUnits={selectedCriteria?.encounterService ?? []}
isAcceptEmptySelection={true}
isDeleteIcon={true}
onChangeExecutiveUnits={_onSubmitExecutiveUnits}
/>
</Grid>

<VisitInputs selectedCriteria={selectedCriteria} onChangeValue={onChangeValue} />

<OccurrencesInputs form={form} selectedCriteria={selectedCriteria} onChangeValue={onChangeValue} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import {
IconButton,
Slider,
Switch,
TextField,
Tooltip,
Typography,
TextField
Typography
} from '@mui/material'
import InfoIcon from '@mui/icons-material/Info'

Expand All @@ -23,11 +23,11 @@ import ProvenanceDestinationInputs from './SupportedInputs/ProvenanceDestination
import OtherInputs from './SupportedInputs/OtherInputs'

import VisitInputs from '../AdvancedInputs/VisitInputs/VisitInputs'
// import { InputAutocompleteAsync as AutocompleteAsync } from 'components/Inputs'

import useStyles from './styles'

import { EncounterDataType } from 'types'
import { EncounterDataType, ScopeTreeRow } from 'types'
import PopulationCard from '../../../../PopulationCard/PopulationCard'
import { STRUCTURE_HOSPITALIERE_DE_PRIS_EN_CHARGE } from 'utils/cohortCreation'

type SupportedFormProps = {
criteria: any
Expand Down Expand Up @@ -106,6 +106,10 @@ const SupportedForm: React.FC<SupportedFormProps> = (props) => {
setDefaultValues(_defaultValues)
}

const _onSubmitExecutiveUnits = (_selectedExecutiveUnits: ScopeTreeRow[] | undefined) => {
_onChangeValue('encounterService', _selectedExecutiveUnits)
}

if (
criteria?.data?.admissionModes === 'loading' ||
criteria?.data?.entryModes === 'loading' ||
Expand Down Expand Up @@ -194,6 +198,17 @@ const SupportedForm: React.FC<SupportedFormProps> = (props) => {
/>
</Grid>

<Grid style={{ display: 'grid', alignItems: 'center', margin: '0 1em' }}>
<PopulationCard
form={'supported'}
label={STRUCTURE_HOSPITALIERE_DE_PRIS_EN_CHARGE}
title={STRUCTURE_HOSPITALIERE_DE_PRIS_EN_CHARGE}
executiveUnits={defaultValues?.encounterService ?? []}
isAcceptEmptySelection={true}
onChangeExecutiveUnits={_onSubmitExecutiveUnits}
/>
</Grid>

<FormLabel style={{ padding: '1em', display: 'flex', alignItems: 'center' }} component="legend">
Âge au moment de la prise en charge
<Tooltip title="La valeur par défaut sera prise en compte si le sélecteur d'âge n'a pas été modifié.">
Expand Down
Loading

0 comments on commit b962d3d

Please sign in to comment.