Skip to content

Commit

Permalink
fix: fixed some criteria label info - Ref gestion-de-projet#2354
Browse files Browse the repository at this point in the history
  • Loading branch information
ManelleG committed Dec 2, 2024
1 parent 7b455fa commit 7c5690c
Show file tree
Hide file tree
Showing 18 changed files with 65 additions and 74 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { CriteriaLabel } from 'components/ui/CriteriaLabel'
import InfoIcon from '@mui/icons-material/Info'
import { isFunction, isString } from 'lodash'
import { SelectedCriteriaType } from 'types/requestCriterias'
import useStyles from '../style'

type CriteriaItemRuntimeProps<T> = {
setError: (error?: string) => void
Expand Down Expand Up @@ -94,12 +95,10 @@ export const CFItem = <T, V extends DataTypeMappings, U extends CriteriaItem<T,
export function CFSection<T extends SelectedCriteriaType>(
props: PropsWithChildren<Omit<CriteriaSection<T>, 'items'> & { collapsed?: boolean }>
) {
const { classes } = useStyles()
return props.title ? (
<BlockWrapper
margin="1em"
// className={classes.inputItem}
>
<Collapse title={props.title} value={!props.defaulCollapsed || !props.collapsed} margin="0">
<BlockWrapper className={classes.inputItem}>
<Collapse title={props.title} value={!props.defaulCollapsed || !props.collapsed}>
{props.children}
</Collapse>
</BlockWrapper>
Expand All @@ -118,6 +117,7 @@ export function CFItemWrapper<T>(
context: Context
}>
) {
const { classes } = useStyles()
const { label, data, context, displayValueSummary, value } = props
const [valueSummary, setValueSummary] = useState<string | undefined>(undefined)

Expand All @@ -135,17 +135,8 @@ export function CFItemWrapper<T>(
((isFunction(label) && label(data as Record<string, DataTypes>, context)) ||
(isString(label) && eval(label)(data, context)))
return (
<BlockWrapper
// ICI ON EST BON SUR LA LARGEUR, NE PAS TOUCHEOOOOOOOOO
// margin={'1em'}
// j'ai touché quand même mais ne fonctionne pas sur les criteria label car la marge des collapse prend le dessus
margin={'1em 1em 0'}
>
{labelValue ? (
<CriteriaLabel label={labelValue} style={{ padding: 0, marginTop: '1em' }} infoIcon={props.info} />
) : (
''
)}
<BlockWrapper className={classes.inputItem}>
{labelValue ? <CriteriaLabel label={labelValue} style={{ marginTop: '1em' }} infoIcon={props.info} /> : ''}
{valueSummary && <Typography style={{ fontWeight: 'bold', marginBottom: '1em' }}>{valueSummary}</Typography>}
{props.children}
</BlockWrapper>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,13 +166,10 @@ const FORM_ITEM_RENDERER: { [key in CriteriaFormItemType]: CriteriaFormItemView<
)
},
radioChoice: (props) => {
// eslint-disable-next-line react-hooks/rules-of-hooks
const { classes } = useStyles()
return (
<RadioGroup
row
style={{ justifyContent: 'space-around' }}
className={classes.inputItem}
aria-label="mode"
name="criteria-mode-radio"
value={props.value}
Expand Down Expand Up @@ -217,8 +214,8 @@ const FORM_ITEM_RENDERER: { [key in CriteriaFormItemType]: CriteriaFormItemView<
onchange={(newCount, newComparator, maxValue) => {
props.updateData({ value: newCount, comparator: newComparator, maxValue: maxValue })
}}
info={props.definition.info}
withHierarchyInfo={props.definition.withHierarchyInfo}
withInfo={props.definition.info}
disabled={props.disabled}
/>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ import { makeStyles } from 'tss-react/mui'

const useStyles = makeStyles()(() => ({
inputItem: {
margin: '1em'
// width: 'calc(100% - 2em)'
margin: '1em 1em 0'
}
}))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ export type NumberWithComparatorCriteriaItem = BaseCriteriaItem &
WithLabel & {
type: 'numberAndComparator'
withHierarchyInfo?: boolean
withInfo?: ReactNode
floatValues?: boolean
allowBetween?: boolean
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ export const form: () => CriteriaForm<ObservationDataType> = () => ({
valueKey: 'occurrence',
type: 'numberAndComparator',
label: "Nombre d'occurrences",
withHierarchyInfo: true,
buildInfo: {
chipDisplayMethodExtraArgs: [{ type: 'string', value: "Nombre d'occurrences" }]
}
Expand All @@ -83,6 +84,7 @@ export const form: () => CriteriaForm<ObservationDataType> = () => ({
}
},
{
// TODO: ajouter une checkbox (??? l'UX était pas top en vrai) pour valider l'ajout d'une recherche par valeur
valueKey: 'searchByValue',
type: 'numberAndComparator',
label: 'Recherche par valeur',
Expand Down Expand Up @@ -132,6 +134,7 @@ export const form: () => CriteriaForm<ObservationDataType> = () => ({
label: 'Début de prise en charge',
labelAltStyle: true,
extraLabel: () => 'Prise en charge',
extraInfo: 'Ne concerne pas les consultations.',
withOptionIncludeNull: true,
buildInfo: {
fhirKey: 'encounter.period-start',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export const form: () => CriteriaForm<CcamDataType> = () => ({
valueKey: 'occurrence',
type: 'numberAndComparator',
label: "Nombre d'occurrences",
withHierarchyInfo: true,
buildInfo: {
chipDisplayMethodExtraArgs: [{ type: 'string', value: "Nombre d'occurrences" }]
}
Expand Down Expand Up @@ -134,6 +135,7 @@ export const form: () => CriteriaForm<CcamDataType> = () => ({
label: 'Début de prise en charge',
labelAltStyle: true,
extraLabel: () => 'Prise en charge',
extraInfo: 'Ne concerne pas les consultations.',
withOptionIncludeNull: true,
buildInfo: {
fhirKey: 'encounter.period-start',
Expand All @@ -156,7 +158,7 @@ export const form: () => CriteriaForm<CcamDataType> = () => ({
valueKey: 'startOccurrence',
type: 'calendarRange',
errorType: 'ADVANCED_INPUTS_ERROR',
extraLabel: () => 'Date de classement en GHM',
extraLabel: () => "Date de l'acte CCAM",
buildInfo: {
fhirKey: ProcedureParamsKeys.DATE,
chipDisplayMethodExtraArgs: [{ type: 'string', value: 'Date de classement en GHM' }]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ export const form: () => CriteriaForm<Cim10DataType> = () => ({
valueKey: 'occurrence',
type: 'numberAndComparator',
label: "Nombre d'occurrences",
withHierarchyInfo: true,
buildInfo: {
chipDisplayMethodExtraArgs: [{ type: 'string', value: "Nombre d'occurrences" }]
}
Expand Down Expand Up @@ -146,6 +147,7 @@ export const form: () => CriteriaForm<Cim10DataType> = () => ({
label: 'Début de prise en charge',
labelAltStyle: true,
extraLabel: () => 'Prise en charge',
extraInfo: 'Ne concerne pas les consultations.',
withOptionIncludeNull: true,
buildInfo: {
fhirKey: 'encounter.period-start',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export const form: () => CriteriaForm<DemographicDataType> = () => ({
{
valueKey: 'birthdates',
type: 'calendarRange',
label: 'Date de naissance',
extraLabel: () => 'Date de naissance',
errorType: 'INCOHERENT_VALUE_ERROR',
displayCondition: (data, context) => {
return !context.deidentified
Expand Down Expand Up @@ -129,7 +129,7 @@ export const form: () => CriteriaForm<DemographicDataType> = () => ({
{
valueKey: 'deathDates',
type: 'calendarRange',
label: 'Date de décès',
extraLabel: () => 'Date de décès',
errorType: 'INCOHERENT_VALUE_ERROR',
displayCondition: (data, context) => {
const typedData = data as DemographicDataType
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ export const form: () => CriteriaForm<DocumentDataType> = () => ({
label: 'Début de prise en charge',
labelAltStyle: true,
extraLabel: () => 'Prise en charge',
extraInfo: 'Ne concerne pas les consultations.',
withOptionIncludeNull: true,
buildInfo: {
fhirKey: 'encounter.period-start',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export const form: () => CriteriaForm<EncounterDataType> = () => ({
valueKey: 'age',
type: 'durationRange',
extraLabel: () => 'Âge au début de la prise en charge',
info: "La valeur par défaut sera prise en compte si le sélecteur d'âge n'a pas été modifié.",
extraInfo: "La valeur par défaut sera prise en compte si le sélecteur d'âge n'a pas été modifié.",
buildInfo: {
fhirKey: {
main: EncounterParamsKeys.MIN_BIRTHDATE_DAY,
Expand All @@ -106,6 +106,7 @@ export const form: () => CriteriaForm<EncounterDataType> = () => ({
valueKey: 'duration',
type: 'durationRange',
extraLabel: () => 'Durée de la prise en charge',
extraInfo: 'Ne concerne pas les consultations.',
buildInfo: {
fhirKey: EncounterParamsKeys.DURATION,
chipDisplayMethodExtraArgs: [{ type: 'string', value: 'Prise en charge : ' }]
Expand All @@ -115,7 +116,8 @@ export const form: () => CriteriaForm<EncounterDataType> = () => ({
valueKey: 'encounterStartDate',
type: 'calendarRange',
label: 'Début de prise en charge',
extraLabel: () => 'Durée de prise en charge',
extraLabel: () => 'Date de prise en charge',
extraInfo: 'Ne concerne pas les consultations.',
labelAltStyle: true,
withOptionIncludeNull: true,
errorType: 'INCOHERENT_VALUE_ERROR',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ export const form: () => CriteriaForm<GhmDataType> = () => ({
valueKey: 'occurrence',
type: 'numberAndComparator',
label: "Nombre d'occurrences",
withHierarchyInfo: true,
buildInfo: {
chipDisplayMethodExtraArgs: [{ type: 'string', value: "Nombre d'occurrences" }]
}
Expand Down Expand Up @@ -112,6 +113,7 @@ export const form: () => CriteriaForm<GhmDataType> = () => ({
label: 'Début de prise en charge',
labelAltStyle: true,
extraLabel: () => 'Prise en charge',
extraInfo: 'Ne concerne pas les consultations.',
withOptionIncludeNull: true,
buildInfo: {
fhirKey: 'encounter.period-start',
Expand All @@ -134,7 +136,7 @@ export const form: () => CriteriaForm<GhmDataType> = () => ({
valueKey: 'startOccurrence',
type: 'calendarRange',
errorType: 'ADVANCED_INPUTS_ERROR',
extraLabel: () => "Date d'acte CCAM",
extraLabel: () => 'Date du classement en GHM',
buildInfo: {
fhirKey: ClaimParamsKeys.DATE,
chipDisplayMethodExtraArgs: [{ type: 'string', value: "Date de l'acte CCAM" }]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export type HospitDataType = CommonCriteriaData &
}

export const form: () => CriteriaForm<HospitDataType> = () => ({
label: "Critère de Fiche d'hopsitalisation",
label: "Critère de Fiche d'hospitalisation",
initialData: {
title: "Critère de Fiche d'hospitalisation",
type: CriteriaType.HOSPIT,
Expand Down Expand Up @@ -447,7 +447,7 @@ export const form: () => CriteriaForm<HospitDataType> = () => ({
{
valueKey: 'birthDeliveryDate',
type: 'calendarRange',
label: "Date/heure de l'accouchement",
extraLabel: () => "Date/heure de l'accouchement",
errorType: 'INCOHERENT_AGE_ERROR',
buildInfo: {
fhirKey: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ export const form: () => CriteriaForm<ImagingDataType> = () => ({
{
valueKey: 'studyDate',
type: 'calendarRange',
label: "Date de l'étude",
extraLabel: () => "Date de l'étude",
errorType: 'INCOHERENT_AGE_ERROR',
buildInfo: {
fhirKey: ImagingParamsKeys.DATE,
Expand Down Expand Up @@ -215,7 +215,7 @@ export const form: () => CriteriaForm<ImagingDataType> = () => ({
{
valueKey: 'seriesDate',
type: 'calendarRange',
label: 'Date de la série',
extraLabel: () => 'Date de la série',
errorType: 'INCOHERENT_AGE_ERROR',
buildInfo: {
fhirKey: ImagingParamsKeys.SERIES_DATE,
Expand Down Expand Up @@ -289,7 +289,7 @@ export const form: () => CriteriaForm<ImagingDataType> = () => ({
type: 'calendarRange',
errorType: 'ADVANCED_INPUTS_ERROR',
label: 'Début de prise en charge',
extraInfo: 'Ne concerne pas les consultations',
extraInfo: 'Ne concerne pas les consultations.',
labelAltStyle: true,
extraLabel: () => 'Prise en charge',
withOptionIncludeNull: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ export const form: () => CriteriaForm<MedicationDataType> = () => ({
valueKey: 'occurrence',
type: 'numberAndComparator',
label: "Nombre d'occurrences",
withHierarchyInfo: true,
buildInfo: {
chipDisplayMethodExtraArgs: [{ type: 'reference', value: "Nombre d'occurrences" }]
}
Expand Down Expand Up @@ -180,6 +181,7 @@ export const form: () => CriteriaForm<MedicationDataType> = () => ({
label: 'Début de prise en charge',
labelAltStyle: true,
extraLabel: () => 'Prise en charge',
extraInfo: 'Ne concerne pas les consultations.',
withOptionIncludeNull: true,
buildInfo: {
fhirKey: {
Expand Down Expand Up @@ -212,7 +214,7 @@ export const form: () => CriteriaForm<MedicationDataType> = () => ({
valueKey: 'startOccurrence',
type: 'calendarRange',
errorType: 'ADVANCED_INPUTS_ERROR',
extraLabel: () => 'Date de classement en GHM',
extraLabel: () => 'Date de début de prescription',
buildInfo: {
fhirKey: {
main: PrescriptionParamsKeys.DATE,
Expand All @@ -234,7 +236,7 @@ export const form: () => CriteriaForm<MedicationDataType> = () => ({
valueKey: 'endOccurrence',
type: 'calendarRange',
errorType: 'ADVANCED_INPUTS_ERROR',
extraLabel: () => 'Date de classement en GHM',
extraLabel: () => 'Date de fin de prescription',
displayCondition: (data) => data.type === CriteriaType.MEDICATION_REQUEST,
buildInfo: {
fhirKey: PrescriptionParamsKeys.END_DATE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,7 @@ export const form: () => CriteriaForm<PregnancyDataType> = () => ({
{
valueKey: 'pregnancyDate',
type: 'calendarRange',
label: 'Date de début de grossesse',
withOptionIncludeNull: true,
extraLabel: () => 'Date de début de grossesse',
errorType: 'INCOHERENT_VALUE_ERROR',
buildInfo: {
fhirKey: {
Expand Down Expand Up @@ -179,7 +178,7 @@ export const form: () => CriteriaForm<PregnancyDataType> = () => ({
valueKey: 'maternalRisksPrecision',
type: 'textWithCheck',
label: 'Risques liés aux antécédents maternels - Précision autre',
placeholder: 'Précision autre',
placeholder: 'Risques liés aux antécédents maternels - Précision autre',
errorType: 'SEARCHINPUT_ERROR',
buildInfo: {
fhirKey: {
Expand Down Expand Up @@ -207,7 +206,7 @@ export const form: () => CriteriaForm<PregnancyDataType> = () => ({
valueKey: 'risksRelatedToObstetricHistoryPrecision',
type: 'textWithCheck',
label: 'Risques liés aux antécédents obstétricaux - précision autre',
placeholder: 'Précision autre',
placeholder: 'Risques liés aux antécédents obstétricaux - Précision autre',
errorType: 'SEARCHINPUT_ERROR',
buildInfo: {
fhirKey: {
Expand Down Expand Up @@ -272,7 +271,7 @@ export const form: () => CriteriaForm<PregnancyDataType> = () => ({
valueKey: 'risksOrComplicationsOfPregnancyPrecision',
type: 'textWithCheck',
label: 'Risques ou complications de la grossesse - Précision autre',
placeholder: 'Précision autre',
placeholder: 'Risques ou complications de la grossesse - Précision autre',
errorType: 'SEARCHINPUT_ERROR',
buildInfo: {
fhirKey: {
Expand Down
5 changes: 2 additions & 3 deletions src/components/ui/Collapse/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@ type CollapseProps = {
value?: boolean
title: string
children: ReactNode
margin?: string
}

const Collapse = ({ value = true, title, children, margin = '0 0 5px 0' }: PropsWithChildren<CollapseProps>) => {
const Collapse = ({ value = true, title, children }: PropsWithChildren<CollapseProps>) => {
const [checked, setChecked] = useState(value)
console.log('test children', children)

Expand All @@ -35,7 +34,7 @@ const Collapse = ({ value = true, title, children, margin = '0 0 5px 0' }: Props
</IconButton>
</Grid>

<CollapseWrapper in={checked} unmountOnExit margin={margin}>
<CollapseWrapper in={checked} unmountOnExit>
{children}
</CollapseWrapper>
</Grid>
Expand Down
13 changes: 2 additions & 11 deletions src/components/ui/Collapse/styles.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,7 @@
import { Collapse, styled } from '@mui/material'

type CustomProps = {
margin?: string
}

export const CollapseWrapper = styled(Collapse)<CustomProps>(({ margin }) => ({
// '& div': {
// margin: margin
// }
'.MuiGrid-root': {
// TODO: trouver un moyen pour qu'ici ça ne se disperse qu'au niveau du premier sous niveau
// ou régler mes problèmes avec CalendarRange, l'outsider
export const CollapseWrapper = styled(Collapse)(() => ({
'& .MuiCollapse-wrapperInner > *': {
margin: '0 0 1em'
}
}))
Loading

0 comments on commit 7c5690c

Please sign in to comment.