Skip to content

Commit

Permalink
fix: export limitation to 5000 lines and fix documentReference encoun…
Browse files Browse the repository at this point in the history
…ter link - Ref gestion-de-projet#2601 gestion-de-projet#2663
  • Loading branch information
Mehdi-BOUYAHIA committed Jul 10, 2024
1 parent bc68f78 commit b72801c
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 20 deletions.
33 changes: 16 additions & 17 deletions src/components/Dashboard/ExportModal/ExportModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,9 @@ const ExportModal: React.FC<ExportModalProps> = ({ cohortId, fhirGroupId, open,
useEffect(() => {
setError(
settings.tables.some((table) => {
return table.checked && table.count > EXPORT_LINES_LIMIT
return (
table.checked && table.count > (table.resourceType === ResourceType.DOCUMENTS ? 5000 : EXPORT_LINES_LIMIT)
)
})
? Error.ERROR_TABLE_LIMIT
: null
Expand Down Expand Up @@ -140,7 +142,9 @@ const ExportModal: React.FC<ExportModalProps> = ({ cohortId, fhirGroupId, open,
newSelectedTables
.filter(
(table) =>
table.checked && (table.count > EXPORT_LINES_LIMIT || !resourcesWithNoFilters.includes(table.resourceType))
table.checked &&
(table.count > (table.resourceType === ResourceType.DOCUMENTS ? 5000 : EXPORT_LINES_LIMIT) ||
!resourcesWithNoFilters.includes(table.resourceType))
)
.map((table) => table.label)
)
Expand Down Expand Up @@ -202,9 +206,10 @@ const ExportModal: React.FC<ExportModalProps> = ({ cohortId, fhirGroupId, open,
const { name, checked, label, resourceType, count } = exportTable
const isItemExpanded = expandedTableIds.includes(label)
const _countLoading = (countLoading && typeof countLoading === 'boolean') || countLoading === label ? true : false
const setLimitError = resourceType === ResourceType.DOCUMENTS ? 5000 : EXPORT_LINES_LIMIT

return (
<ExportTableAccordion key={label} expanded={isItemExpanded} error={checked && count > EXPORT_LINES_LIMIT}>
<ExportTableAccordion key={label} expanded={isItemExpanded} error={checked && count > setLimitError}>
<ExportTableAccordionSummary
style={resourcesWithNoFilters.includes(resourceType) ? { cursor: 'default' } : {}}
expandIcon={
Expand Down Expand Up @@ -360,14 +365,6 @@ const ExportModal: React.FC<ExportModalProps> = ({ cohortId, fhirGroupId, open,
onChange={(e) => handleChangeSettings('motif', e.target.value)}
/>

<Grid className={classes.warningInfo} container alignItems="center">
<WarningIcon className={classes.warningIcon} color="warning" fontSize="small" />
<Typography className={classes.warningNote}>
La biologie (table <i>measurement</i>) et les comptes-rendus (table <i>note</i>) ne sont pas disponibles à
l’export csv.
</Typography>
</Grid>

<Grid container py="28px" gap="16px">
<Grid item container alignItems="center" flexWrap="nowrap" pr="33px">
<Grid item container>
Expand Down Expand Up @@ -630,12 +627,14 @@ const ExportTable: React.FC<ExportTableProps> = ({
</RadioGroup>
</Grid>
</Grid>
{exportTable.checked && exportTable.count > EXPORT_LINES_LIMIT && (
<Typography color={'red'} fontWeight={'bold'} fontSize={12}>
La table sélectionnée dépasse la limite de {EXPORT_LINES_LIMIT} lignes autorisées. Veuillez affiner votre
sélection à l'aide de filtres ou désélectionner la table.
</Typography>
)}
{exportTable.checked &&
exportTable.count > (exportTable.resourceType === ResourceType.DOCUMENTS ? 5000 : EXPORT_LINES_LIMIT) && (
<Typography color={'red'} fontWeight={'bold'} fontSize={12}>
La table sélectionnée dépasse la limite de{' '}
{exportTable.resourceType === ResourceType.DOCUMENTS ? 5000 : EXPORT_LINES_LIMIT} lignes autorisées.
Veuillez affiner votre sélection à l'aide de filtres ou désélectionner la table.
</Typography>
)}
</Grid>
)
}
8 changes: 6 additions & 2 deletions src/services/aphp/callApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ type fetchEncounterProps = {
signal?: AbortSignal
}
export const fetchEncounter = async (args: fetchEncounterProps): FHIR_Bundle_Promise_Response<Encounter> => {
const { _id, size, offset, _sort, sortDirection, patient, visit, signal } = args
const { _id, size, offset, _sort, sortDirection, patient, visit = false, signal } = args
const _sortDirection = sortDirection === Direction.DESC ? '-' : ''
let { _list, _elements, status, facet } = args

Expand All @@ -195,7 +195,11 @@ export const fetchEncounter = async (args: fetchEncounterProps): FHIR_Bundle_Pro
if (status && status.length > 0) options = [...options, `status=${status.reduce(paramValuesReducer)}`]
if (_elements && _elements.length > 0) options = [...options, `_elements=${_elements.reduce(paramValuesReducer, '')}`]
if (facet && facet.length > 0) options = [...options, `facet=${facet.reduce(paramValuesReducer, '')}`]
visit ? (options = [...options, `part-of:missing=true`]) : (options = [...options, `part-of:missing=false`])
if (visit) {
options = [...options, `part-of:missing=true`]
} else {
options = [...options, `part-of:missing=false`]
}

const response = await apiFhir.get<FHIR_Bundle_Response<Encounter>>(`/Encounter?${options.reduce(paramsReducer)}`, {
signal: signal
Expand Down
3 changes: 2 additions & 1 deletion src/utils/fillElement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ export const getResourceInfos = async <
_id: listeEncounterIds,
_list: groupId ? [groupId] : [],
_elements: ['status', 'serviceProvider', 'identifier', 'partOf'],
signal: signal
signal: signal,
visit: true
})
if (encounters.data.resourceType !== 'Bundle' || !encounters.data.entry) {
return []
Expand Down

0 comments on commit b72801c

Please sign in to comment.