Skip to content

Commit

Permalink
refactor: cleaned types - Ref gestion-de-projet#2070
Browse files Browse the repository at this point in the history
* refactor: cleaned types - Ref gestion-de-projet#2070

* fix: resolve import problem due to rebase with main

* refactor: correct some type problem - Ref gestion-de-projet#2070

* refactor: correct some type problem - Ref gestion-de-projet#2070

* refactor: correct some type problem - Ref gestion-de-projet#2070

---------

Co-authored-by: Salah-BOUYAHIA <salah.bouyahia-ext@aphp.fr>
  • Loading branch information
ManelleG and Mehdi-BOUYAHIA authored Jun 20, 2024
1 parent 2fa10ed commit a606c8d
Show file tree
Hide file tree
Showing 97 changed files with 863 additions and 957 deletions.
30 changes: 15 additions & 15 deletions src/components/CohortsTable/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,11 @@ const ResearchTable: React.FC<ResearchTableProps> = ({
const meState = useAppSelector((state) => state.me)
const maintenanceIsActive = meState?.maintenance?.active

const onClickRow = (row: any) => {
const onClickRow = (row: Cohort) => {
if (
row.request_job_status === CohortJobStatus._pending ||
row.request_job_status === CohortJobStatus._long_pending ||
row.request_job_status === CohortJobStatus._failed
row.request_job_status === CohortJobStatus.PENDING ||
row.request_job_status === CohortJobStatus.LONG_PENDING ||
row.request_job_status === CohortJobStatus.FAILED
)
return
navigate(`/cohort/${row.fhir_group_id}`)
Expand Down Expand Up @@ -262,7 +262,7 @@ const ResearchTable: React.FC<ResearchTableProps> = ({
return (
<TableRow
className={
row.request_job_status === CohortJobStatus._finished ? classes.pointerHover : classes.notAllow
row.request_job_status === CohortJobStatus.FINISHED ? classes.pointerHover : classes.notAllow
}
hover
key={row.uuid}
Expand All @@ -284,12 +284,12 @@ const ResearchTable: React.FC<ResearchTableProps> = ({
</IconButton>
</TableCell>
<TableCell onClick={() => onClickRow(row)} align="center">
{row.request_job_status === CohortJobStatus._finished ? (
{row.request_job_status === CohortJobStatus.FINISHED ? (
<Chip label="Terminé" size="small" style={{ backgroundColor: '#28a745', color: 'white' }} />
) : row.request_job_status === CohortJobStatus._pending ||
row.request_job_status === CohortJobStatus._new ? (
) : row.request_job_status === CohortJobStatus.PENDING ||
row.request_job_status === CohortJobStatus.NEW ? (
<Chip label="En cours" size="small" style={{ backgroundColor: '#ffc107', color: 'black' }} />
) : row.request_job_status === CohortJobStatus._long_pending ? (
) : row.request_job_status === CohortJobStatus.LONG_PENDING ? (
<Tooltip title="Cohorte volumineuse: sa création est plus complexe et nécessite d'être placée dans une file d'attente. Un mail vous sera envoyé quand celle-ci sera disponible.">
<Chip
label="En cours"
Expand Down Expand Up @@ -346,11 +346,11 @@ const ResearchTable: React.FC<ResearchTableProps> = ({
title={
!row.exportable
? 'Cette cohorte ne peut pas être exportée car elle dépasse le seuil de nombre de patients maximum autorisé.'
: !canExportThisCohort && row.request_job_status === CohortJobStatus._finished
: !canExportThisCohort && row.request_job_status === CohortJobStatus.FINISHED
? "Vous n'avez pas les droits suffisants pour exporter cette cohorte."
: row.request_job_status === CohortJobStatus._failed
: row.request_job_status === CohortJobStatus.FAILED
? 'Cette cohorte ne peut pas être exportée car elle a échoué lors de sa création'
: row.request_job_status === CohortJobStatus._pending
: row.request_job_status === CohortJobStatus.PENDING
? 'Cette cohorte ne peut pas être exportée car elle est en cours de création'
: ''
}
Expand All @@ -366,9 +366,9 @@ const ResearchTable: React.FC<ResearchTableProps> = ({
!canExportThisCohort ||
!row.exportable ||
maintenanceIsActive ||
row.request_job_status === CohortJobStatus._long_pending ||
row.request_job_status === CohortJobStatus._failed ||
row.request_job_status === CohortJobStatus._pending
row.request_job_status === CohortJobStatus.LONG_PENDING ||
row.request_job_status === CohortJobStatus.FAILED ||
row.request_job_status === CohortJobStatus.PENDING
}
>
<ExportIcon />
Expand Down
4 changes: 2 additions & 2 deletions src/components/CreationCohort/ControlPanel/ControlPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ const ControlPanel: React.FC<{
const webSocketContext = useContext(WebSocketContext)

useEffect(() => {
if (status && status === CohortJobStatus._new) {
if (status && status === CohortJobStatus.NEW) {
setCountLoading(LoadingStatus.FETCHING)
dispatch(countCohortCreation({ uuid: uuid }))
}
Expand All @@ -233,7 +233,7 @@ const ControlPanel: React.FC<{
message.status === WebSocketJobStatus.finished &&
message.extra_info?.measure !== null
) {
setPatientCount(message.extra_info.measure)
setPatientCount(message.extra_info?.measure)
setCountLoading(LoadingStatus.SUCCESS)
}
}
Expand Down
52 changes: 15 additions & 37 deletions src/components/CreationCohort/DataList_Criteria.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { CriteriaItemType } from 'types'

// Components
import RequestForm from './DiagramView/components/LogicalOperator/components/CriteriaRightPanel/RequestForm/RequestForm'
import IPPForm from './DiagramView/components/LogicalOperator/components/CriteriaRightPanel/IPPForm/IPPForm'
import DocumentsForm from './DiagramView/components/LogicalOperator/components/CriteriaRightPanel/DocumentsForm/DocumentsForm'
Expand All @@ -18,56 +17,35 @@ import HospitForm from './DiagramView/components/LogicalOperator/components/Crit
import services from 'services/aphp'

import { ODD_BIOLOGY, ODD_IMAGING, ODD_MEDICATION } from '../../constants'
import { CriteriaType } from 'types/requestCriterias'

// ├── Mes requêtes
// ├── Liste d'IPP
// ├── Patients
// ├── Visites
// ├── Documents cliniques
// ├── PMSI
// │ ├── Diagnostics
// │ ├── Actes
// │ ├── GHM
// ├── Médicaments
// │ ├── Prescription - Dispension - Administration
// ├── Biologie/Microbiologie
// │ ├── Biologie
// │ ├── Microbiologie
// ├── Dossiers de spécialité
// | ├── Maternité
// | | ├── Fiche Grossesse
// | | ├── Hospitalisation
// ├── Imagerie
// ├── Physiologie
import { CriteriaType, CriteriaTypeLabels } from 'types/requestCriterias'

const criteriaList: CriteriaItemType[] = [
{
id: 'Request',
title: 'Mes requêtes',
title: CriteriaTypeLabels.REQUEST,
color: '#0063AF',
fontWeight: 'bold',
components: RequestForm
},
{
id: 'IPPList',
title: "Liste d'IPP",
title: CriteriaTypeLabels.IPP_LIST,
color: '#0063AF',
fontWeight: 'bold',
components: IPPForm,
disabled: true
},
{
id: 'Patient',
title: 'Démographie',
title: CriteriaTypeLabels.PATIENT,
color: '#0063AF',
fontWeight: 'bold',
components: DemographicForm,
fetch: { gender: services.cohortCreation.fetchGender, status: services.cohortCreation.fetchStatus }
},
{
id: 'Encounter',
title: 'Prise en charge',
title: CriteriaTypeLabels.ENCOUNTER,
color: '#0063AF',
fontWeight: 'bold',
components: EncounterForm,
Expand All @@ -87,7 +65,7 @@ const criteriaList: CriteriaItemType[] = [
},
{
id: 'DocumentReference',
title: 'Documents cliniques',
title: CriteriaTypeLabels.DOCUMENTS,
color: '#0063AF',
fontWeight: 'bold',
components: DocumentsForm,
Expand All @@ -98,14 +76,14 @@ const criteriaList: CriteriaItemType[] = [
},
{
id: 'pmsi',
title: 'PMSI',
title: CriteriaTypeLabels.PMSI,
color: '#0063AF',
fontWeight: 'bold',
components: null,
subItems: [
{
id: 'Condition',
title: 'Diagnostics',
title: CriteriaTypeLabels.CONDITION,
color: '#0063AF',
fontWeight: 'normal',
components: Cim10Form,
Expand All @@ -118,7 +96,7 @@ const criteriaList: CriteriaItemType[] = [
},
{
id: 'Procedure',
title: 'Actes',
title: CriteriaTypeLabels.PROCEDURE,
color: '#0063AF',
fontWeight: 'normal',
components: CCAMForm,
Expand All @@ -129,7 +107,7 @@ const criteriaList: CriteriaItemType[] = [
},
{
id: 'Claim',
title: 'GHM',
title: CriteriaTypeLabels.CLAIM,
color: '#0063AF',
fontWeight: 'normal',
components: GhmForm,
Expand Down Expand Up @@ -157,14 +135,14 @@ const criteriaList: CriteriaItemType[] = [
},
{
id: 'biologie_microbiologie',
title: 'Biologie/Microbiologie',
title: CriteriaTypeLabels.BIO_MICRO,
color: !!ODD_BIOLOGY ? '#0063AF' : '#808080',
fontWeight: 'bold',
components: null,
subItems: [
{
id: 'Observation',
title: 'Biologie',
title: CriteriaTypeLabels.OBSERVATION,
color: !!ODD_BIOLOGY ? '#0063AF' : '#808080',
fontWeight: 'normal',
components: !!ODD_BIOLOGY ? BiologyForm : null,
Expand All @@ -176,7 +154,7 @@ const criteriaList: CriteriaItemType[] = [
},
{
id: 'microbiologie',
title: 'Microbiologie',
title: CriteriaTypeLabels.MICROBIOLOGIE,
components: null,
color: '#808080',
fontWeight: 'normal',
Expand Down Expand Up @@ -263,7 +241,7 @@ const criteriaList: CriteriaItemType[] = [
},
{
id: 'ImagingStudy',
title: 'Imagerie',
title: CriteriaTypeLabels.IMAGING,
color: ODD_IMAGING ? '#0063AF' : '#808080',
fontWeight: 'bold',
components: ODD_IMAGING ? ImagingForm : null,
Expand All @@ -275,7 +253,7 @@ const criteriaList: CriteriaItemType[] = [
},
{
id: 'physiologie',
title: 'Physiologie',
title: CriteriaTypeLabels.PHYSIOLOGIE,
color: '#808080',
fontWeight: 'bold',
disabled: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import CriteriaRightPanel from './components/CriteriaRightPanel/CriteriaRightPan
import { AvatarWrapper } from 'components/ui/Avatar/styles'
import CriteriaCardItem from '../CriteriaCard'

import { CriteriaGroupType } from 'types'
import { CriteriaGroup, CriteriaGroupType } from 'types'

import { useAppDispatch, useAppSelector } from 'state'
import {
Expand Down Expand Up @@ -51,7 +51,7 @@ const OperatorItem: React.FC<OperatorItemProps> = ({

const maintenanceIsActive = useAppSelector((state) => state.me?.maintenance?.active ?? false)

const displayingItem = criteriaGroup.filter((_criteriaGroup: CriteriaGroupType) => _criteriaGroup.id === itemId)
const displayingItem = criteriaGroup.filter((_criteriaGroup: CriteriaGroup) => _criteriaGroup.id === itemId)

let timeout: NodeJS.Timeout | null = null

Expand All @@ -77,9 +77,9 @@ const OperatorItem: React.FC<OperatorItemProps> = ({
<div className={classes.operatorChild}>
{displayingItem &&
displayingItem.map(({ criteriaIds }) => {
const children: (CriteriaGroupType | SelectedCriteriaType | undefined)[] = criteriaIds
const children: (CriteriaGroup | SelectedCriteriaType | undefined)[] = criteriaIds
.map((criteriaId: number) => {
let foundItem: CriteriaGroupType | SelectedCriteriaType | undefined = criteriaGroup.find(
let foundItem: CriteriaGroup | SelectedCriteriaType | undefined = criteriaGroup.find(
({ id }) => id === criteriaId
)
if (!foundItem) {
Expand Down Expand Up @@ -215,10 +215,11 @@ const LogicalOperator: React.FC = () => {
const currentParent = request.criteriaGroup ? request.criteriaGroup.find(({ id }) => id === parentId) : null
if (!currentParent) return
const nextGroupId = request.nextGroupId
const newOperator: CriteriaGroupType = {
const newOperator: CriteriaGroup = {
id: nextGroupId,
title: 'Groupe de critères',
type: currentParent.type === 'orGroup' ? 'andGroup' : 'orGroup',
type:
currentParent.type === CriteriaGroupType.OR_GROUP ? CriteriaGroupType.AND_GROUP : CriteriaGroupType.OR_GROUP,
criteriaIds: [],
isSubGroup: parentId === 0 ? false : true,
isInclusive: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,43 @@ import InfoIcon from '@mui/icons-material/Info'

import PopulationCard from 'components/CreationCohort/DiagramView/components/PopulationCard/PopulationCard'
import VisitInputs from './VisitInputs/VisitInputs'
import { CriteriaNameType } from 'types'
import { CriteriaName } from 'types'
import OccurrencesDateInputs from './OccurrencesInputs/OccurrencesDateInputs'

import scopeType from 'data/scope_type.json'

import { ScopeTreeRow } from 'types'
import {
CcamDataType,
Cim10DataType,
DocumentDataType,
GhmDataType,
ImagingDataType,
MedicationDataType,
ObservationDataType
} from 'types/requestCriterias'

type AdvancedInputsProps = {
form: CriteriaNameType
selectedCriteria: any
onChangeValue: (key: string, value: any) => void
form: CriteriaName
selectedCriteria:
| CcamDataType
| Cim10DataType
| DocumentDataType
| GhmDataType
| MedicationDataType
| ImagingDataType
| ObservationDataType
onChangeValue: (key: string, value: ScopeTreeRow[] | string | undefined) => void
}

const AdvancedInputs: React.FC<AdvancedInputsProps> = (props) => {
const { form, selectedCriteria = {}, onChangeValue } = props
const { form, selectedCriteria, onChangeValue } = props
const optionsIsUsed =
selectedCriteria?.encounterService?.length > 0 ||
!!selectedCriteria?.startOccurrence ||
!!selectedCriteria?.endOccurrence ||
!!selectedCriteria?.encounterStartDate ||
!!selectedCriteria?.encounterEndDate
(selectedCriteria.encounterService && selectedCriteria.encounterService.length > 0) ||
!!selectedCriteria.startOccurrence ||
!!selectedCriteria.endOccurrence ||
!!selectedCriteria.encounterStartDate ||
!!selectedCriteria.encounterEndDate

const [checked, setCheck] = useState(optionsIsUsed)
const label = 'Sélectionnez une unité exécutrice'
Expand Down Expand Up @@ -77,7 +93,7 @@ const AdvancedInputs: React.FC<AdvancedInputsProps> = (props) => {
form={form}
label={label}
title={label}
executiveUnits={selectedCriteria?.encounterService ?? []}
executiveUnits={selectedCriteria.encounterService ?? []}
isAcceptEmptySelection={true}
isDeleteIcon={true}
onChangeExecutiveUnits={_onSubmitExecutiveUnits}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,32 @@ import { FormControl, FormLabel, Grid, IconButton, Input, InputLabel } from '@mu
import ClearIcon from '@mui/icons-material/Clear'

import useStyles from './styles'
import {
CcamDataType,
Cim10DataType,
DocumentDataType,
EncounterDataType,
GhmDataType,
HospitDataType,
ImagingDataType,
MedicationDataType,
ObservationDataType,
PregnancyDataType
} from 'types/requestCriterias'

type OccurrenceDateInputsProps = {
selectedCriteria: any
onChangeValue: (key: string, value: any) => void
selectedCriteria:
| CcamDataType
| Cim10DataType
| DocumentDataType
| GhmDataType
| EncounterDataType
| PregnancyDataType
| HospitDataType
| MedicationDataType
| ObservationDataType
| ImagingDataType
onChangeValue: (key: string, value: string) => void
}

const OccurrenceDateInputs: React.FC<OccurrenceDateInputsProps> = (props) => {
Expand Down
Loading

0 comments on commit a606c8d

Please sign in to comment.