diff --git a/src/services/aphp/callApi.ts b/src/services/aphp/callApi.ts index 50d707cd8..e81a210ec 100644 --- a/src/services/aphp/callApi.ts +++ b/src/services/aphp/callApi.ts @@ -609,16 +609,20 @@ export const fetchMedicationAdministration = async (args: fetchMedicationAdminis type fetchScopeProps = { perimetersIds?: string[] cohortIds?: string[] + types?: string[] } export const fetchScope: (args: fetchScopeProps) => Promise> = async ( args: fetchScopeProps ) => { - const { perimetersIds, cohortIds } = args + const { perimetersIds, cohortIds, types } = args let options: string[] = [] if (perimetersIds && perimetersIds.length > 0) options = [...options, `local_id=${perimetersIds.join(',')}`] // eslint-disable-line if (cohortIds && cohortIds.length > 0) options = [...options, `cohort_id=${cohortIds.join(',')}`] // eslint-disable-line + if (types && types.length > 0) options = [...options, `type_source_value=${types.join(',')}`] // eslint-disable-line - const response: AxiosResponse = await apiBackend.get(`accesses/perimeters/read-patient/?${options}`) + const response: AxiosResponse = await apiBackend.get( + `accesses/perimeters/read-patient/?${options.reduce(optionsReducer)}` + ) return response } diff --git a/src/services/aphp/servicePerimeters.ts b/src/services/aphp/servicePerimeters.ts index e6cc86bf6..ad110522a 100644 --- a/src/services/aphp/servicePerimeters.ts +++ b/src/services/aphp/servicePerimeters.ts @@ -63,7 +63,8 @@ export interface IServicePerimeters { defaultPerimetersIds?: string[], cohortIds?: string[], noPerimetersIdsFetch?: boolean, - signal?: AbortSignal + signal?: AbortSignal, + types?: string[] ) => Promise /** @@ -228,7 +229,8 @@ const servicesPerimeters: IServicePerimeters = { defaultPerimetersIds?: string[], cohortIds?: string[], noPerimetersIdsFetch?: boolean, - signal?: AbortSignal + signal?: AbortSignal, + types?: string[] ) => { try { let perimetersIds: string[] | undefined = [] @@ -252,7 +254,11 @@ const servicesPerimeters: IServicePerimeters = { perimetersIds = defaultPerimetersIds } - const perimetersListReponse: any = await fetchScope({ perimetersIds: perimetersIds, cohortIds: cohortIds }) + const perimetersListReponse: any = await fetchScope({ + perimetersIds: perimetersIds, + cohortIds: cohortIds, + types: types + }) if (!perimetersListReponse || !perimetersListReponse.data || !perimetersListReponse.data.results) { console.error( 'Error (getPerimeters) while fetching perimeter (from back) ! perimeters = {}, cohortIds = {}', @@ -296,11 +302,15 @@ const servicesPerimeters: IServicePerimeters = { getScopeSubItems: async (subScopesIds: string | null | undefined, getSubItem?: boolean, signal?: AbortSignal) => { if (!subScopesIds) return [] + + const types = ['AP-HP', 'GHU', 'Hôpital', 'Groupe hospitalier (GH)', 'Pôle/DMU', 'Unité Fonctionnelle (UF)'] + const subScopes: ScopePage[] = await servicesPerimeters.getPerimeters( subScopesIds.trim().split(','), undefined, undefined, - signal + signal, + types ) const scopeRowList: ScopeTreeRow[] = await servicesPerimeters.buildScopeTreeRow(subScopes, getSubItem, signal) return scopeRowList