Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
Mehdi-BOUYAHIA committed Dec 9, 2024
1 parent 8f21820 commit 4e2c82f
Show file tree
Hide file tree
Showing 17 changed files with 1,183 additions and 23 deletions.
8 changes: 5 additions & 3 deletions src/components/Dashboard/ExportModal/ExportModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -695,12 +695,14 @@ const ExportTable: React.FC<ExportTableProps> = ({
renderOption={(props, option) => <li {...props}>{option.name}</li>}
renderInput={(params) => <TextField {...params} label="Sélectionnez un filtre" />}
value={exportTable.fhir_filter}
onChange={(_, value) => _onChangeValue(value)}
onChange={(_, value) => {
_onChangeValue(value)
}}
/>
</Grid>
</Grid>
)}
<Grid item container alignItems="center" justifyContent="space-between" display="none">
{/* <Grid item container alignItems="center" justifyContent="space-between" display="none">
<Grid item xs={5}>
<Typography className={classes.textBody2}>
Filtrer cette table en respectant les contraintes relationnelles avec les autres tables sélectionnées:
Expand All @@ -722,7 +724,7 @@ const ExportTable: React.FC<ExportTableProps> = ({
</Grid>
</RadioGroup>
</Grid>
</Grid>
</Grid> */}
{exportTable.checked &&
exportTable.count > (exportTable.resourceType === ResourceType.DOCUMENTS ? 5000 : exportLinesLimit) && (
<Typography color={'red'} fontWeight={'bold'} fontSize={12}>
Expand Down
99 changes: 80 additions & 19 deletions src/components/Dashboard/ExportModal/exportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -378,8 +378,8 @@ export const fetchAllResourcesCount = async (cohortId: string) => {
observationCount,
imagingCount,
encounterVisitCount,
encounterDetailsCounts,
questionnaireResponseCount
encounterDetailsCounts
// questionnaireResponseCount
] = await Promise.all([
fetchPatientCount(cohortId),
fetchConditionCount(cohortId),
Expand All @@ -391,8 +391,8 @@ export const fetchAllResourcesCount = async (cohortId: string) => {
fetchObservationCount(cohortId),
fetchImagingCount(cohortId),
fetchEncounterCount(cohortId, true),
fetchEncounterCount(cohortId),
fetchQuestionnaireCount(cohortId)
fetchEncounterCount(cohortId)
// fetchQuestionnaireCount(cohortId)
])

return {
Expand All @@ -406,8 +406,8 @@ export const fetchAllResourcesCount = async (cohortId: string) => {
observationCount,
imagingCount,
encounterVisitCount,
encounterDetailsCounts,
questionnaireResponseCount
encounterDetailsCounts
// questionnaireResponseCount
}
} catch (error) {
console.error('Erreur lors de fetchQuestionnaireCount', error)
Expand Down Expand Up @@ -435,19 +435,7 @@ export const fetchResourceCount = async (cohortId: string, table: ExportCSVTable
[ResourceType.IMAGING]: fetchImagingCount
}

const fetcher =
fetchers[
resourceType as
| ResourceType.PATIENT
| ResourceType.CONDITION
| ResourceType.PROCEDURE
| ResourceType.CLAIM
| ResourceType.DOCUMENTS
| ResourceType.MEDICATION_REQUEST
| ResourceType.MEDICATION_ADMINISTRATION
| ResourceType.OBSERVATION
| ResourceType.IMAGING
]
const fetcher = fetchers[resourceType as keyof typeof fetchers]

return (await fetcher(cohortId, filters)) ?? 0
} catch (error) {
Expand All @@ -471,3 +459,76 @@ export const getRightCount = (counts: Counts, tableResourceType: ResourcesWithEx

return countMapping[tableResourceType] ?? 0
}

export const fetchResourceCount2 = async (cohortId: string, resourceType: ResourceType, fhirFilter?: any) => {
try {
const filters = await mapRequestParamsToSearchCriteria(fhirFilter?.filter ?? '', resourceType)
const fetchers = {
[ResourceType.PATIENT]: fetchPatientCount,
[ResourceType.CONDITION]: fetchConditionCount,
[ResourceType.PROCEDURE]: fetchProcedureCount,
[ResourceType.CLAIM]: fetchClaimCount,
[ResourceType.DOCUMENTS]: fetchDocumentsCount,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
[ResourceType.MEDICATION_REQUEST]: (cohortId: string, filters: any) =>
fetchMedicationCount(cohortId, ResourceType.MEDICATION_REQUEST, filters),
// eslint-disable-next-line @typescript-eslint/no-explicit-any
[ResourceType.MEDICATION_ADMINISTRATION]: (cohortId: string, filters: any) =>
fetchMedicationCount(cohortId, ResourceType.MEDICATION_ADMINISTRATION, filters),
[ResourceType.OBSERVATION]: fetchObservationCount,
[ResourceType.IMAGING]: fetchImagingCount
}

const fetcher = fetchers[resourceType as keyof typeof fetchers]

return (await fetcher(cohortId, filters)) ?? 0
} catch (error) {
console.error('Erreur lors du fetch du count de la ressource', error)
throw error
}
}

export const getResourceType = (tableName: string): ResourceType => {
const resourceType = {
imaging_study: ResourceType.IMAGING,
drug_exposure_administration: ResourceType.MEDICATION_ADMINISTRATION,
measurement: ResourceType.OBSERVATION,
imaging_series: ResourceType.UNKNOWN,
condition_occurrence: ResourceType.CONDITION,
iris: ResourceType.UNKNOWN,
visit_detail: ResourceType.UNKNOWN,
person: ResourceType.PATIENT,
note: ResourceType.DOCUMENTS,
fact_relationship: ResourceType.UNKNOWN,
care_site: ResourceType.UNKNOWN,
visit_occurrence: ResourceType.UNKNOWN,
cost: ResourceType.CLAIM,
procedure_occurrence: ResourceType.PROCEDURE,
drug_exposure_prescription: ResourceType.MEDICATION_REQUEST,
questionnaireresponse: ResourceType.UNKNOWN
}[tableName]

return resourceType ?? ResourceType.UNKNOWN
}

export const getExportTableLabel = (tableName: string) => {
const tableLabel = {
imaging_study: 'Fait - Imagerie - Étude',
drug_exposure_administration: 'Fait - Médicaments - Administration',
measurement: 'Fait - Biologie',
imaging_series: 'Fait - Imagerie - Séries',
condition_occurrence: 'Fait - PMSI - Diagnostics',
care_site: 'Structure hospitalière',
iris: 'Zone géographique',
visit_detail: 'Détail de prise en charge',
person: 'Patient',
note: 'Fait - Documents cliniques',
fact_relationship: 'Référentiel',
visit_occurrence: 'Prise en charge',
cost: 'Fait - PMSI - GHM',
procedure_occurrence: 'Fait - PMSI - Actes',
drug_exposure_prescription: 'Fait - Médicaments - Prescription',
QuestionnaireResponse: 'Formulaires'
}[tableName]
return tableLabel ?? '-'
}
39 changes: 39 additions & 0 deletions src/components/Routes/AppNavigation/config.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ import CareSiteView from 'views/Scope/CareSiteView'
import MyCohorts from 'views/MyCohorts'
import MyRequests from 'views/MyRequests'
import DownloadPopup from 'views/DownloadPopup/DownloadPopup'
import Export from 'pages/Export'
import ExportRequest from 'pages/ExportRequest'
import FeasibilityReports from 'pages/FeasibilityReports'

// import { ODD_CONTACT } from '../../../constants'

Expand Down Expand Up @@ -217,6 +220,42 @@ const configRoutes: configRoute[] = [
element: <Patient />,
exact: false
},

/**
* Cohort360: Export Page
*/
{
path: '/exports',
name: '/exports',
isPrivate: true,
element: <Export />,
exact: true,
displaySideBar: true
},
{
path: '/exports/new',
name: '/exports/new',
isPrivate: true,
element: <ExportRequest />,
exact: true,
displaySideBar: true
},

/**
* Cohort360: Feasibility Reports Page
*/
{
path: '/feasibility-reports',
name: '/feasibility-reports',
isPrivate: true,
element: <FeasibilityReports />,
exact: true,
displaySideBar: true
},

/**
* Cohort360: Export download Page
*/
{
path: '/download/:resource/:itemId',
name: '/download/:resource/:itemId',
Expand Down
20 changes: 20 additions & 0 deletions src/components/Routes/LeftSideBar/LeftSideBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,26 @@ const LeftSideBar: React.FC<{ open?: boolean }> = (props) => {
Mes requêtes
</Link>
</ListItem>
<ListItem>
<Link
id="exports-link"
onClick={() => navigate('/exports')}
underline="hover"
className={classes.nestedTitle}
>
Mes exports
</Link>
</ListItem>
<ListItem>
<Link
id="feasibility-reports-link"
onClick={() => navigate('/feasibility-reports')}
underline="hover"
className={classes.nestedTitle}
>
Mes rapports de faisabilite
</Link>
</ListItem>
</List>
</Collapse>
</List>
Expand Down
11 changes: 11 additions & 0 deletions src/components/Tables/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import React from 'react'

const TableLines: React.FC = () => {
return (
<div>
<h1>Tables lines</h1>
</div>
)
}

export default TableLines
21 changes: 21 additions & 0 deletions src/components/ui/HeaderPage/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import React from 'react'

import { Grid, Typography } from '@mui/material'

type HeaderPageProps = {
id: string
title: string
}

const HeaderPage: React.FC<HeaderPageProps> = (props) => {
const { id, title } = props
return (
<Grid item xs={12} margin="60px 0">
<Typography id={id} variant="h1" color="primary" padding="20px 0" borderBottom="1px solid #D0D7D8">
{title}
</Typography>
</Grid>
)
}

export default HeaderPage
6 changes: 5 additions & 1 deletion src/config.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ type AppConfig = {
export: {
enabled: boolean
exportLinesLimit: number
exportTables: string
}
observation: {
enabled: boolean
Expand Down Expand Up @@ -144,6 +145,7 @@ type AppConfig = {
wsProtocol: string
fhirUrl: string
backendUrl: string
datamodelUrl: string
oidc?: {
issuer: string
redirectUri: string
Expand Down Expand Up @@ -196,7 +198,8 @@ let config: AppConfig = {
},
export: {
enabled: true,
exportLinesLimit: 300000
exportLinesLimit: 300000,
exportTables: ''
},
observation: {
enabled: true,
Expand Down Expand Up @@ -291,6 +294,7 @@ let config: AppConfig = {
wsProtocol: 'ws://',
backendUrl: '/api/back',
fhirUrl: '/api/fhir',
datamodelUrl: '/api/datamodel2',
sessionTimeout: 780000,
refreshTokenInterval: 180000,
codeDisplayJWT: 'ArrowUp,ArrowUp,ArrowDown,ArrowDown,ArrowLeft,ArrowRight,ArrowLeft,ArrowRight,b,a,Enter',
Expand Down
48 changes: 48 additions & 0 deletions src/pages/Export/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import React from 'react'

import { Grid, CssBaseline } from '@mui/material'

import HeaderPage from 'components/ui/HeaderPage'
import DataTable from 'components/DataTable/DataTable'
import Tables from 'components/Tables'

import { useAppSelector } from 'state'

import sideBarTransition from 'styles/sideBarTransition'

const exportColumnsTable = [
{ label: 'N° de cohorte' },
{ label: 'Nom de la cohorte' },
{ label: 'Nombre de patient' },
{ label: "Nom de l'export" },
{ label: 'Date de l’export' },
{ label: 'Statut' },
{ label: 'Actions' }
]

const Export: React.FC = () => {
const { classes, cx } = sideBarTransition()
const openDrawer = useAppSelector((state) => state.drawer)

return (
<Grid
container
direction="column"
className={cx(classes.appBar, {
[classes.appBarShift]: openDrawer
})}
>
<Grid container justifyContent="center" alignItems="center">
<CssBaseline />
<Grid container item xs={11}>
<HeaderPage id="export-page-title" title="Mes exports" />
<DataTable columns={exportColumnsTable}>
<p>salut</p>
</DataTable>
</Grid>
</Grid>
</Grid>
)
}

export default Export
Loading

0 comments on commit 4e2c82f

Please sign in to comment.