Skip to content

Commit

Permalink
fix(perimeter): set correct cohort data type
Browse files Browse the repository at this point in the history
  • Loading branch information
pl-buiquang committed Sep 19, 2024
1 parent a2a207b commit 574d975
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import ArrowBackIcon from '@mui/icons-material/ArrowBack'
import { capitalizeFirstLetter } from 'utils/capitalize'

import useStyles from './styles'
import { ScopeElement } from 'types'

type PatientTitleProps = {
firstName: string | undefined
Expand All @@ -30,9 +31,9 @@ const PatientTitle: React.FC<PatientTitleProps> = ({ firstName, lastName }) => {
const goBacktoCohort = () => {
const path =
cohort.cohort && Array.isArray(cohort.cohort) && cohort.cohort.length > 0
? `/perimeters/patients?${cohort.cohort.map((e) => e.id).join()}`
: !Array.isArray(cohort.cohort) && cohort.cohort?.id
? `/cohort/${cohort.cohort?.id}/patients`
? `/perimeters/patients?${cohort.cohort.map((e: ScopeElement) => e.cohort_id).join()}`
: !Array.isArray(cohort.cohort) && cohort.cohort?.cohort_id
? `/cohort/${cohort.cohort?.cohort_id}/patients`
: groupId
? `/perimeters/patients?${groupId}`
: '/my-patients/patients'
Expand Down
4 changes: 1 addition & 3 deletions src/services/aphp/servicePatients.ts
Original file line number Diff line number Diff line change
Expand Up @@ -822,9 +822,7 @@ const servicesPatients: IServicePatients = {
const perimetersResponse = await servicesPerimeters.getPerimeters({ cohortIds: groupId })

if (perimetersResponse.results.length > 0) {
const perimeterRights = await servicesPerimeters.fetchPerimetersRights(
perimetersResponse.results as unknown as Group[]
)
const perimeterRights = await servicesPerimeters.fetchPerimetersRights(perimetersResponse.results)
return perimeterRights.some(
(right) => getExtension(right, 'READ_ACCESS')?.valueString === 'DATA_PSEUDOANONYMISED'
)
Expand Down
4 changes: 2 additions & 2 deletions src/services/aphp/servicePerimeters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export interface IServicePerimeters {
* Arguments:
* - perimetersId: ID du périmètre (liste d'ID séparé par des virgules)
*/
fetchPerimetersRights: (perimetersResponse: Group[]) => Promise<Group[]>
fetchPerimetersRights: (perimetersResponse: ScopeElement[]) => Promise<ScopeElement[]>

/**
* à travers un ScopePage on retourne 'Nominatif' ou 'Pseudonymisé' selon les droits d'accès
Expand Down Expand Up @@ -145,7 +145,7 @@ const servicesPerimeters: IServicePerimeters = {

const perimeters = djangoResponse.results

const cohort = await servicesPerimeters.fetchPerimetersRights(perimeters as unknown as Group[])
const cohort = await servicesPerimeters.fetchPerimetersRights(perimeters)

const totalPatients = patientsResp?.data?.resourceType === 'Bundle' ? patientsResp.data.total : 0

Expand Down
2 changes: 1 addition & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ export type VisiteRepartitionType = {
export type CohortData = {
name?: string
description?: string
cohort?: Group | Group[]
cohort?: ScopeElement | ScopeElement[]
totalPatients?: number
originalPatients?: CohortPatient[]
totalDocs?: number
Expand Down

0 comments on commit 574d975

Please sign in to comment.