diff --git a/src/components/CreationCohort/DiagramView/components/LogicalOperator/components/CriteriaRightPanel/AdvancedInputs/AdvancedInputs.tsx b/src/components/CreationCohort/DiagramView/components/LogicalOperator/components/CriteriaRightPanel/AdvancedInputs/AdvancedInputs.tsx index 5b96f0030..9dc672a9b 100644 --- a/src/components/CreationCohort/DiagramView/components/LogicalOperator/components/CriteriaRightPanel/AdvancedInputs/AdvancedInputs.tsx +++ b/src/components/CreationCohort/DiagramView/components/LogicalOperator/components/CriteriaRightPanel/AdvancedInputs/AdvancedInputs.tsx @@ -12,14 +12,11 @@ import { Hierarchy } from 'types/hierarchy' import { ScopeElement } from 'types' import CalendarRange from 'components/ui/Inputs/CalendarRange' -import { - CriteriaType, - CriteriaTypesWithAdvancedInputs, - SelectedCriteriaTypesWithAdvancedInputs -} from 'types/requestCriterias' +import { CriteriaType, SelectedCriteriaTypesWithAdvancedInputs } from 'types/requestCriterias' import { BlockWrapper } from 'components/ui/Layout' import { DurationRangeType } from 'types/searchCriterias' import { CriteriaLabel } from 'components/ui/CriteriaLabel' +import { getOccurenceDateLabel } from 'utils/requestCriterias' type AdvancedInputsProps = { sourceType: SourceType @@ -31,8 +28,10 @@ type AdvancedInputsProps = { const AdvancedInputs = ({ sourceType, selectedCriteria, onChangeValue, onError }: AdvancedInputsProps) => { const optionsIsUsed = (selectedCriteria.encounterService && selectedCriteria.encounterService.length > 0) || - !!selectedCriteria.startOccurrence || - !!selectedCriteria.endOccurrence || + selectedCriteria.startOccurrence?.[0] !== null || + selectedCriteria.startOccurrence?.[1] !== null || + selectedCriteria.endOccurrence?.[0] !== null || + selectedCriteria.endOccurrence?.[1] !== null || selectedCriteria.encounterStartDate[0] !== null || selectedCriteria.encounterStartDate[1] !== null || selectedCriteria.encounterEndDate[0] !== null || @@ -44,22 +43,6 @@ const AdvancedInputs = ({ sourceType, selectedCriteria, onChangeValue, onError } onChangeValue('encounterService', _selectedExecutiveUnits) } - const getOccurenceDateLabel = ( - selectedCriteriaType: Exclude - ) => { - const mapping = { - [CriteriaType.DOCUMENTS]: 'Date de création du document', - [CriteriaType.CONDITION]: 'Date du diagnostic CIM10', - [CriteriaType.PROCEDURE]: "Date de l'acte CCAM", - [CriteriaType.CLAIM]: 'Date du classement en GHM', - [CriteriaType.MEDICATION_REQUEST]: 'Date de prescription', - [CriteriaType.MEDICATION_ADMINISTRATION]: "Date de début d'administration", - [CriteriaType.OBSERVATION]: "Date de l'examen" - } - - return mapping[selectedCriteriaType] - } - return ( {selectedCriteria.type !== CriteriaType.IMAGING && ( - - {getOccurenceDateLabel(selectedCriteria.type)} - { - onChangeValue('startOccurrence', start) - onChangeValue('endOccurrence', end) - }} - onError={(isError) => onError(isError)} - /> - + <> + + {getOccurenceDateLabel(selectedCriteria.type)} + { + onChangeValue('startOccurrence', newDate) + }} + onError={(isError) => onError(isError)} + /> + + {selectedCriteria.type === CriteriaType.MEDICATION_REQUEST && ( + + {getOccurenceDateLabel(selectedCriteria.type, true)} + { + onChangeValue('endOccurrence', newDate) + }} + onError={(isError) => onError(isError)} + /> + + )} + )} diff --git a/src/components/CreationCohort/DiagramView/components/LogicalOperator/components/CriteriaRightPanel/BiologyForm/index.tsx b/src/components/CreationCohort/DiagramView/components/LogicalOperator/components/CriteriaRightPanel/BiologyForm/index.tsx index 78c75f074..5673b70ac 100644 --- a/src/components/CreationCohort/DiagramView/components/LogicalOperator/components/CriteriaRightPanel/BiologyForm/index.tsx +++ b/src/components/CreationCohort/DiagramView/components/LogicalOperator/components/CriteriaRightPanel/BiologyForm/index.tsx @@ -23,8 +23,7 @@ export const defaultBiology: Omit = { searchByValue: [null, null], occurrence: 1, occurrenceComparator: Comparators.GREATER_OR_EQUAL, - startOccurrence: '', - endOccurrence: '', + startOccurrence: [null, null], isInclusive: true, encounterStartDate: [null, null], encounterEndDate: [null, null], diff --git a/src/components/CreationCohort/DiagramView/components/LogicalOperator/components/CriteriaRightPanel/CCAM/index.tsx b/src/components/CreationCohort/DiagramView/components/LogicalOperator/components/CriteriaRightPanel/CCAM/index.tsx index c5d9fd4fb..c395cf165 100644 --- a/src/components/CreationCohort/DiagramView/components/LogicalOperator/components/CriteriaRightPanel/CCAM/index.tsx +++ b/src/components/CreationCohort/DiagramView/components/LogicalOperator/components/CriteriaRightPanel/CCAM/index.tsx @@ -23,8 +23,7 @@ export const defaultProcedure: Omit = { occurrence: 1, hierarchy: undefined, occurrenceComparator: Comparators.GREATER_OR_EQUAL, - startOccurrence: '', - endOccurrence: '', + startOccurrence: [null, null], isInclusive: true, encounterStartDate: [null, null], encounterEndDate: [null, null], diff --git a/src/components/CreationCohort/DiagramView/components/LogicalOperator/components/CriteriaRightPanel/Cim10Form/index.tsx b/src/components/CreationCohort/DiagramView/components/LogicalOperator/components/CriteriaRightPanel/Cim10Form/index.tsx index d2f0f6f32..fadc12a81 100644 --- a/src/components/CreationCohort/DiagramView/components/LogicalOperator/components/CriteriaRightPanel/Cim10Form/index.tsx +++ b/src/components/CreationCohort/DiagramView/components/LogicalOperator/components/CriteriaRightPanel/Cim10Form/index.tsx @@ -22,8 +22,7 @@ export const defaultCondition: Omit = { diagnosticType: [], occurrence: 1, occurrenceComparator: Comparators.GREATER_OR_EQUAL, - startOccurrence: '', - endOccurrence: '', + startOccurrence: [null, null], isInclusive: true, encounterStartDate: [null, null], encounterEndDate: [null, null], diff --git a/src/components/CreationCohort/DiagramView/components/LogicalOperator/components/CriteriaRightPanel/DocumentsForm/DocumentsForm.tsx b/src/components/CreationCohort/DiagramView/components/LogicalOperator/components/CriteriaRightPanel/DocumentsForm/DocumentsForm.tsx index f70e89907..842444616 100644 --- a/src/components/CreationCohort/DiagramView/components/LogicalOperator/components/CriteriaRightPanel/DocumentsForm/DocumentsForm.tsx +++ b/src/components/CreationCohort/DiagramView/components/LogicalOperator/components/CriteriaRightPanel/DocumentsForm/DocumentsForm.tsx @@ -51,8 +51,7 @@ const defaultComposition: Omit = { encounterEndDate: [null, null], includeEncounterStartDateNull: false, includeEncounterEndDateNull: false, - startOccurrence: '', - endOccurrence: '', + startOccurrence: [null, null], isInclusive: true, docStatuses: [], encounterStatus: [] diff --git a/src/components/CreationCohort/DiagramView/components/LogicalOperator/components/CriteriaRightPanel/EncounterForm/index.tsx b/src/components/CreationCohort/DiagramView/components/LogicalOperator/components/CriteriaRightPanel/EncounterForm/index.tsx index 25ac5da53..10cba58de 100644 --- a/src/components/CreationCohort/DiagramView/components/LogicalOperator/components/CriteriaRightPanel/EncounterForm/index.tsx +++ b/src/components/CreationCohort/DiagramView/components/LogicalOperator/components/CriteriaRightPanel/EncounterForm/index.tsx @@ -152,6 +152,7 @@ const EncounterForm = ({ occurrence, occurrenceComparator, encounterStatus, + startOccurrence: [null, null], isInclusive, title, type: CriteriaType.ENCOUNTER diff --git a/src/components/CreationCohort/DiagramView/components/LogicalOperator/components/CriteriaRightPanel/GHM/index.tsx b/src/components/CreationCohort/DiagramView/components/LogicalOperator/components/CriteriaRightPanel/GHM/index.tsx index d7eec0e42..88af99817 100644 --- a/src/components/CreationCohort/DiagramView/components/LogicalOperator/components/CriteriaRightPanel/GHM/index.tsx +++ b/src/components/CreationCohort/DiagramView/components/LogicalOperator/components/CriteriaRightPanel/GHM/index.tsx @@ -20,8 +20,7 @@ export const defaultClaim: Omit = { label: undefined, occurrence: 1, occurrenceComparator: Comparators.GREATER_OR_EQUAL, - startOccurrence: '', - endOccurrence: '', + startOccurrence: [null, null], isInclusive: true, encounterStartDate: [null, null], encounterEndDate: [null, null], diff --git a/src/components/CreationCohort/DiagramView/components/LogicalOperator/components/CriteriaRightPanel/HospitForm/index.tsx b/src/components/CreationCohort/DiagramView/components/LogicalOperator/components/CriteriaRightPanel/HospitForm/index.tsx index 56a9ab811..b605525fa 100644 --- a/src/components/CreationCohort/DiagramView/components/LogicalOperator/components/CriteriaRightPanel/HospitForm/index.tsx +++ b/src/components/CreationCohort/DiagramView/components/LogicalOperator/components/CriteriaRightPanel/HospitForm/index.tsx @@ -262,6 +262,7 @@ const HospitForm = ({ occurrenceComparator, encounterStatus, isInclusive, + startOccurrence: [null, null], title }) } diff --git a/src/components/CreationCohort/DiagramView/components/LogicalOperator/components/CriteriaRightPanel/ImagingForm/index.tsx b/src/components/CreationCohort/DiagramView/components/LogicalOperator/components/CriteriaRightPanel/ImagingForm/index.tsx index 8d613ffcf..c9a8850d1 100644 --- a/src/components/CreationCohort/DiagramView/components/LogicalOperator/components/CriteriaRightPanel/ImagingForm/index.tsx +++ b/src/components/CreationCohort/DiagramView/components/LogicalOperator/components/CriteriaRightPanel/ImagingForm/index.tsx @@ -163,7 +163,8 @@ const ImagingForm: React.FC = (props) => { includeEncounterStartDateNull, encounterEndDate, includeEncounterEndDateNull, - encounterStatus + encounterStatus, + startOccurrence: [null, null] }) } diff --git a/src/components/CreationCohort/DiagramView/components/LogicalOperator/components/CriteriaRightPanel/MedicationForm/components/Form/MedicationForm.tsx b/src/components/CreationCohort/DiagramView/components/LogicalOperator/components/CriteriaRightPanel/MedicationForm/components/Form/MedicationForm.tsx index 58dc29c8d..513e8dde2 100644 --- a/src/components/CreationCohort/DiagramView/components/LogicalOperator/components/CriteriaRightPanel/MedicationForm/components/Form/MedicationForm.tsx +++ b/src/components/CreationCohort/DiagramView/components/LogicalOperator/components/CriteriaRightPanel/MedicationForm/components/Form/MedicationForm.tsx @@ -1,4 +1,4 @@ -import React, { useState } from 'react' +import React, { useEffect, useState } from 'react' import { Alert, @@ -66,6 +66,12 @@ const MedicationForm: React.FC = (props) => { ) const [error, setError] = useState(Error.NO_ERROR) + useEffect(() => { + if (currentState.type === CriteriaType.MEDICATION_ADMINISTRATION) { + onChangeValue('endOccurrence', [null, null]) + } + }, [currentState.type]) + const getMedicationOptions = async (searchValue: string, signal: AbortSignal) => { const response = await services.cohortCreation.fetchMedicationData(searchValue, false, signal) return response.map((elem) => { diff --git a/src/components/CreationCohort/DiagramView/components/LogicalOperator/components/CriteriaRightPanel/MedicationForm/index.tsx b/src/components/CreationCohort/DiagramView/components/LogicalOperator/components/CriteriaRightPanel/MedicationForm/index.tsx index 75bf83c0d..dee1c6f4e 100644 --- a/src/components/CreationCohort/DiagramView/components/LogicalOperator/components/CriteriaRightPanel/MedicationForm/index.tsx +++ b/src/components/CreationCohort/DiagramView/components/LogicalOperator/components/CriteriaRightPanel/MedicationForm/index.tsx @@ -21,8 +21,8 @@ export const defaultMedication: Omit = { administration: [], occurrence: 1, occurrenceComparator: Comparators.GREATER_OR_EQUAL, - startOccurrence: '', - endOccurrence: '', + startOccurrence: [null, null], + endOccurrence: [null, null], encounterEndDate: [null, null], encounterStartDate: [null, null], isInclusive: true, diff --git a/src/components/CreationCohort/DiagramView/components/LogicalOperator/components/CriteriaRightPanel/PregnantForm/index.tsx b/src/components/CreationCohort/DiagramView/components/LogicalOperator/components/CriteriaRightPanel/PregnantForm/index.tsx index 0d45d9e0b..c2597d9b4 100644 --- a/src/components/CreationCohort/DiagramView/components/LogicalOperator/components/CriteriaRightPanel/PregnantForm/index.tsx +++ b/src/components/CreationCohort/DiagramView/components/LogicalOperator/components/CriteriaRightPanel/PregnantForm/index.tsx @@ -140,8 +140,7 @@ const PregnantForm = ({ encounterService, occurrence, occurrenceComparator, - startOccurrence: null, - endOccurrence: null, + startOccurrence: [null, null], encounterStatus, isInclusive, title diff --git a/src/mappers/filters.ts b/src/mappers/filters.ts index 36c6605b1..727be6df4 100644 --- a/src/mappers/filters.ts +++ b/src/mappers/filters.ts @@ -121,6 +121,7 @@ export enum PrescriptionParamsKeys { NDA = 'encounter.identifier', PRESCRIPTION_TYPES = 'category', DATE = 'validity-period-start', + END_DATE = 'validity-period-end', CODE = 'code', EXECUTIVE_UNITS = 'encounter.encounter-care-site', ENCOUNTER_STATUS = 'encounter.status', diff --git a/src/types/requestCriterias.ts b/src/types/requestCriterias.ts index 7d8e6723c..e06139703 100644 --- a/src/types/requestCriterias.ts +++ b/src/types/requestCriterias.ts @@ -94,8 +94,8 @@ export type CommonCriteriaDataType = { export type WithOccurenceCriteriaDataType = { occurrence?: number | null occurrenceComparator?: Comparators | null - startOccurrence?: string | null - endOccurrence?: string | null + startOccurrence: DurationRangeType + endOccurrence?: DurationRangeType } export type WithEncounterDateDataType = { diff --git a/src/utils/cohortCreation.ts b/src/utils/cohortCreation.ts index 8adf82146..76588e014 100644 --- a/src/utils/cohortCreation.ts +++ b/src/utils/cohortCreation.ts @@ -380,8 +380,8 @@ const constructFilterFhir = (criterion: SelectedCriteriaType, deidentified: bool ) ), filtersBuilders(DocumentsParamsKeys.DOC_STATUSES, buildLabelObjectFilter(criterion.encounterStatus)), - filtersBuilders(DocumentsParamsKeys.DATE, buildDateFilter(criterion.startOccurrence, 'ge')), - filtersBuilders(DocumentsParamsKeys.DATE, buildDateFilter(criterion.endOccurrence, 'le')), + filtersBuilders(DocumentsParamsKeys.DATE, buildDateFilter(criterion.startOccurrence[0], 'ge')), + filtersBuilders(DocumentsParamsKeys.DATE, buildDateFilter(criterion.startOccurrence[1], 'le')), buildEncounterDateFilter( criterion.type, criterion.includeEncounterStartDateNull, @@ -403,8 +403,8 @@ const constructFilterFhir = (criterion: SelectedCriteriaType, deidentified: bool criterion.source ? buildSimpleFilter(criterion.source, ProcedureParamsKeys.SOURCE) : '', filtersBuilders(ConditionParamsKeys.EXECUTIVE_UNITS, buildEncounterServiceFilter(criterion.encounterService)), filtersBuilders(ConditionParamsKeys.ENCOUNTER_STATUS, buildLabelObjectFilter(criterion.encounterStatus)), - filtersBuilders(ConditionParamsKeys.DATE, buildDateFilter(criterion.startOccurrence, 'ge')), - filtersBuilders(ConditionParamsKeys.DATE, buildDateFilter(criterion.endOccurrence, 'le')), + filtersBuilders(ConditionParamsKeys.DATE, buildDateFilter(criterion.startOccurrence[0], 'ge')), + filtersBuilders(ConditionParamsKeys.DATE, buildDateFilter(criterion.startOccurrence[1], 'le')), buildEncounterDateFilter( criterion.type, criterion.includeEncounterStartDateNull, @@ -424,8 +424,8 @@ const constructFilterFhir = (criterion: SelectedCriteriaType, deidentified: bool filtersBuilders(ProcedureParamsKeys.CODE, buildLabelObjectFilter(criterion.code, PROCEDURE_HIERARCHY)), filtersBuilders(ProcedureParamsKeys.EXECUTIVE_UNITS, buildEncounterServiceFilter(criterion.encounterService)), filtersBuilders(ProcedureParamsKeys.ENCOUNTER_STATUS, buildLabelObjectFilter(criterion.encounterStatus)), - filtersBuilders(ProcedureParamsKeys.DATE, buildDateFilter(criterion.startOccurrence, 'ge')), - filtersBuilders(ProcedureParamsKeys.DATE, buildDateFilter(criterion.endOccurrence, 'le')), + filtersBuilders(ProcedureParamsKeys.DATE, buildDateFilter(criterion.startOccurrence[0], 'ge')), + filtersBuilders(ProcedureParamsKeys.DATE, buildDateFilter(criterion.startOccurrence[1], 'le')), criterion.source ? buildSimpleFilter(criterion.source, ProcedureParamsKeys.SOURCE) : '', buildEncounterDateFilter( criterion.type, @@ -446,8 +446,8 @@ const constructFilterFhir = (criterion: SelectedCriteriaType, deidentified: bool filtersBuilders(ClaimParamsKeys.CODE, buildLabelObjectFilter(criterion.code, CLAIM_HIERARCHY)), filtersBuilders(ClaimParamsKeys.EXECUTIVE_UNITS, buildEncounterServiceFilter(criterion.encounterService)), filtersBuilders(ClaimParamsKeys.ENCOUNTER_STATUS, buildLabelObjectFilter(criterion.encounterStatus)), - filtersBuilders(ClaimParamsKeys.DATE, buildDateFilter(criterion.startOccurrence, 'ge')), - filtersBuilders(ClaimParamsKeys.DATE, buildDateFilter(criterion.endOccurrence, 'le')), + filtersBuilders(ClaimParamsKeys.DATE, buildDateFilter(criterion.startOccurrence[0], 'ge')), + filtersBuilders(ClaimParamsKeys.DATE, buildDateFilter(criterion.startOccurrence[1], 'le')), buildEncounterDateFilter( criterion.type, criterion.includeEncounterStartDateNull, @@ -488,14 +488,16 @@ const constructFilterFhir = (criterion: SelectedCriteriaType, deidentified: bool criterion.type === CriteriaType.MEDICATION_REQUEST ? PrescriptionParamsKeys.DATE : AdministrationParamsKeys.DATE, - buildDateFilter(criterion.startOccurrence, 'ge') + buildDateFilter(criterion.startOccurrence[0], 'ge') ), filtersBuilders( criterion.type === CriteriaType.MEDICATION_REQUEST ? PrescriptionParamsKeys.DATE : AdministrationParamsKeys.DATE, - buildDateFilter(criterion.endOccurrence, 'le') + buildDateFilter(criterion.startOccurrence[1], 'le') ), + filtersBuilders(PrescriptionParamsKeys.END_DATE, buildDateFilter(criterion.endOccurrence?.[0], 'ge')), + filtersBuilders(PrescriptionParamsKeys.END_DATE, buildDateFilter(criterion.endOccurrence?.[1], 'le')), criterion.type === CriteriaType.MEDICATION_REQUEST ? filtersBuilders( PrescriptionParamsKeys.PRESCRIPTION_TYPES, @@ -524,8 +526,8 @@ const constructFilterFhir = (criterion: SelectedCriteriaType, deidentified: bool ), filtersBuilders(ObservationParamsKeys.EXECUTIVE_UNITS, buildEncounterServiceFilter(criterion.encounterService)), filtersBuilders(ObservationParamsKeys.ENCOUNTER_STATUS, buildLabelObjectFilter(criterion.encounterStatus)), - filtersBuilders(ObservationParamsKeys.DATE, buildDateFilter(criterion.startOccurrence, 'ge')), - filtersBuilders(ObservationParamsKeys.DATE, buildDateFilter(criterion.endOccurrence, 'le')), + filtersBuilders(ObservationParamsKeys.DATE, buildDateFilter(criterion.startOccurrence[0], 'ge')), + filtersBuilders(ObservationParamsKeys.DATE, buildDateFilter(criterion.startOccurrence[1], 'le')), buildObservationValueFilter(criterion, ObservationParamsKeys.VALUE), buildEncounterDateFilter( criterion.type, @@ -1004,8 +1006,7 @@ const unbuildEncounterCriteria = async (element: RequeteurCriteriaType): Promise admission: [], encounterService: [], occurrence: null, - startOccurrence: null, - endOccurrence: null, + startOccurrence: [null, null], encounterStartDate: [null, null], encounterEndDate: [null, null], encounterStatus: [] @@ -1128,8 +1129,7 @@ const unbuildDocumentReferenceCriteria = async (element: RequeteurCriteriaType): docStatuses: [], occurrence: null, occurrenceComparator: null, - startOccurrence: null, - endOccurrence: null, + startOccurrence: [null, null], encounterService: [], encounterEndDate: [null, null], encounterStartDate: [null, null], @@ -1171,9 +1171,9 @@ const unbuildDocumentReferenceCriteria = async (element: RequeteurCriteriaType): } case DocumentsParamsKeys.DATE: { if (value?.includes('ge')) { - currentCriterion.startOccurrence = unbuildDateFilter(value) + currentCriterion.startOccurrence[0] = unbuildDateFilter(value) } else if (value?.includes('le')) { - currentCriterion.endOccurrence = unbuildDateFilter(value) + currentCriterion.startOccurrence[1] = unbuildDateFilter(value) } break } @@ -1218,8 +1218,7 @@ const unbuildConditionCriteria = async (element: RequeteurCriteriaType): Promise source: null, diagnosticType: [], occurrence: null, - startOccurrence: null, - endOccurrence: null, + startOccurrence: [null, null], encounterService: [], encounterEndDate: [null, null], encounterStartDate: [null, null], @@ -1259,9 +1258,9 @@ const unbuildConditionCriteria = async (element: RequeteurCriteriaType): Promise } case ConditionParamsKeys.DATE: { if (value?.includes('ge')) { - currentCriterion.startOccurrence = unbuildDateFilter(value) + currentCriterion.startOccurrence[0] = unbuildDateFilter(value) } else if (value?.includes('le')) { - currentCriterion.endOccurrence = unbuildDateFilter(value) + currentCriterion.startOccurrence[1] = unbuildDateFilter(value) } break } @@ -1302,8 +1301,7 @@ const unbuildProcedureCriteria = async (element: RequeteurCriteriaType): Promise title: element.name ?? "Critères d'actes CCAM", code: [], occurrence: null, - startOccurrence: null, - endOccurrence: null, + startOccurrence: [null, null], source: null, label: undefined, hierarchy: undefined, @@ -1343,9 +1341,9 @@ const unbuildProcedureCriteria = async (element: RequeteurCriteriaType): Promise } case ProcedureParamsKeys.DATE: { if (value?.includes('ge')) { - currentCriterion.startOccurrence = unbuildDateFilter(value) + currentCriterion.startOccurrence[0] = unbuildDateFilter(value) } else if (value?.includes('le')) { - currentCriterion.endOccurrence = unbuildDateFilter(value) + currentCriterion.startOccurrence[1] = unbuildDateFilter(value) } break } @@ -1384,8 +1382,7 @@ const unbuildClaimCriteria = async (element: RequeteurCriteriaType): Promise, + endOccurrence?: boolean +) => { + const mapping = { + [CriteriaType.DOCUMENTS]: 'Date de création du document', + [CriteriaType.CONDITION]: 'Date du diagnostic CIM10', + [CriteriaType.PROCEDURE]: "Date de l'acte CCAM", + [CriteriaType.CLAIM]: 'Date du classement en GHM', + [CriteriaType.MEDICATION_REQUEST]: endOccurrence ? 'Date de fin de prescription' : 'Date de début de prescription', + [CriteriaType.MEDICATION_ADMINISTRATION]: "Date de début d'administration", + [CriteriaType.OBSERVATION]: "Date de l'examen" + } + + return mapping[selectedCriteriaType] +} + const getMedicationTypeLabel = (type: CriteriaType) => { switch (type) { case CriteriaType.MEDICATION_REQUEST: @@ -891,8 +909,28 @@ export const criteriasAsArray = (selectedCriteria: SelectedCriteriaType, criteri "Nombre d'occurrences" ) ) - if (selectedCriteria.startOccurrence || selectedCriteria.endOccurrence) - labels.push(getDatesLabel([selectedCriteria.startOccurrence, selectedCriteria.endOccurrence], 'Occurence')) + if (selectedCriteria.startOccurrence?.[0] !== null || selectedCriteria.startOccurrence?.[1] !== null) + labels.push( + getDatesLabel( + selectedCriteria.startOccurrence, + getOccurenceDateLabel( + selectedCriteria.type as Exclude + ) + ) + ) + if ( + selectedCriteria.endOccurrence && + (selectedCriteria.endOccurrence?.[0] !== null || selectedCriteria.endOccurrence?.[1] !== null) + ) + labels.push( + getDatesLabel( + selectedCriteria.endOccurrence ?? [null, null], + getOccurenceDateLabel( + selectedCriteria.type as Exclude + ), + true + ) + ) if (selectedCriteria.encounterService && selectedCriteria.encounterService.length > 0) labels.push(getLabelFromName(selectedCriteria.encounterService)) if (selectedCriteria.encounterStatus && selectedCriteria.encounterStatus.length > 0)