Skip to content

Commit

Permalink
fix: Replace route pop-children by read-patient
Browse files Browse the repository at this point in the history
  • Loading branch information
Mehdi-BOUYAHIA committed Mar 9, 2023
1 parent 2186a48 commit 065026f
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/services/aphp/servicePerimeters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,10 +233,10 @@ const servicesPerimeters: IServicePerimeters = {
try {
let perimetersIds: string[] | undefined = []
let perimetersList: ScopePage[] = []
let rightsData: any[] = []
let rightsData: any = []
if (!defaultPerimetersIds && !noPerimetersIdsFetch) {
const rightResponse = await apiBackend.get('accesses/accesses/my-rights/?pop-children', { signal: signal })
rightsData = rightResponse.status === 200 ? (rightResponse?.data as any[]) : []
const rightResponse = await apiBackend.get('accesses/perimeters/read-patient/', { signal: signal })
rightsData = rightResponse.status === 200 ? (rightResponse?.data as any) : ''

if (rightResponse.status !== 200) {
const backError: any = {
Expand All @@ -247,7 +247,7 @@ const servicesPerimeters: IServicePerimeters = {
return []
}

perimetersIds = rightsData.map((rightData) => rightData.care_site_id)
perimetersIds = rightsData.results.map((rightData: any) => rightData.perimeter.id)
} else {
perimetersIds = defaultPerimetersIds
}
Expand All @@ -264,8 +264,8 @@ const servicesPerimeters: IServicePerimeters = {
perimetersList = perimetersListReponse.data.results.map((perimeterItem: any) => {
let read_access = undefined
if (!defaultPerimetersIds) {
const foundRight = rightsData.find(
(rightData) => rightData.care_site_id === +(perimeterItem.perimeter.id ?? '0')
const foundRight = rightsData.results.find(
(rightData: any) => rightData.perimeter.id === +(perimeterItem.perimeter.id ?? '0')
)
read_access = foundRight?.right_read_patient_nominative ? 'DATA_NOMINATIVE' : 'DATA_PSEUDOANONYMISED'
}
Expand Down

0 comments on commit 065026f

Please sign in to comment.