Skip to content

Commit

Permalink
correc mapping valueset + mapping encounter status
Browse files Browse the repository at this point in the history
  • Loading branch information
aetchego committed Dec 20, 2024
1 parent 64d52c2 commit ab562bc
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src/components/CreationCohort/DataList_Criteria.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Back_API_Response, CriteriaItemType } from 'types'

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'
import DocumentsForm from './DiagramView/components/LogicalOperator/components/CriteriaRightPanel/DocumentsForm'
import EncounterForm from './DiagramView/components/LogicalOperator/components/CriteriaRightPanel/EncounterForm'
import CCAMForm from './DiagramView/components/LogicalOperator/components/CriteriaRightPanel/CcamForm'
import Cim10Form from './DiagramView/components/LogicalOperator/components/CriteriaRightPanel/Cim10Form'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
Button
} from '@mui/material'
import useStyles from '../formStyles'
import { Comparators, ObservationDataType, CriteriaType } from 'types/requestCriterias'
import { Comparators, ObservationDataType, CriteriaType, CriteriaDataKey } from 'types/requestCriterias'
import { CriteriaDrawerComponentProps } from 'types'
import { getConfig } from 'config'
import KeyboardBackspaceIcon from '@mui/icons-material/KeyboardBackspace'
Expand All @@ -27,6 +27,7 @@ import AdvancedInputs from '../AdvancedInputs'
import { SourceType } from 'types/scope'
import { getValueSetsFromSystems } from 'utils/valueSets'
import { HIERARCHY_ROOT } from 'services/aphp/serviceValueSets'
import { mappingCriteria } from '../DemographicForm'

enum Error {
NO_ERROR,
Expand Down Expand Up @@ -127,7 +128,9 @@ const BiologyForm = (props: CriteriaDrawerComponentProps) => {
)
)
.filter((e) => e)
setCurrentCriteria({ ...currentCriteria, code: foundCodes })
const encounterStatus =
mappingCriteria(currentCriteria?.encounterStatus, CriteriaDataKey.ENCOUNTER_STATUS, criteriaData) || []
setCurrentCriteria({ ...currentCriteria, code: foundCodes, encounterStatus })
}, [])

Check warning on line 134 in src/components/CreationCohort/DiagramView/components/LogicalOperator/components/CriteriaRightPanel/BiologyForm/index.tsx

View workflow job for this annotation

GitHub Actions / test

React Hook useEffect has missing dependencies: 'criteriaData' and 'currentCriteria'. Either include them or remove the dependency array. You can also do a functional update 'setCurrentCriteria(c => ...)' if you only need 'currentCriteria' in the 'setCurrentCriteria' call

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,15 @@ import useStyles from '../formStyles'
import KeyboardBackspaceIcon from '@mui/icons-material/KeyboardBackspace'

import { CriteriaDrawerComponentProps } from 'types'
import { CcamDataType, Comparators, CriteriaType } from 'types/requestCriterias'
import { CcamDataType, Comparators, CriteriaDataKey, CriteriaType } from 'types/requestCriterias'
import { BlockWrapper } from 'components/ui/Layout'
import OccurenceInput from 'components/ui/Inputs/Occurences'
import AdvancedInputs from '../AdvancedInputs'
import { SourceType } from 'types/scope'
import ValueSetField from 'components/SearchValueSet/ValueSetField'
import { getConfig } from 'config'
import { getValueSetsFromSystems } from 'utils/valueSets'
import { mappingCriteria } from '../DemographicForm'

enum Error {
ADVANCED_INPUTS_ERROR,
Expand Down Expand Up @@ -70,7 +71,9 @@ const CcamForm = (props: CriteriaDrawerComponentProps) => {
)
)
.filter((e) => e)
setCurrentCriteria({ ...currentCriteria, code: foundCodes })
const encounterStatus =
mappingCriteria(currentCriteria?.encounterStatus, CriteriaDataKey.ENCOUNTER_STATUS, criteriaData) || []
setCurrentCriteria({ ...currentCriteria, code: foundCodes, encounterStatus })
}, [])

Check warning on line 77 in src/components/CreationCohort/DiagramView/components/LogicalOperator/components/CriteriaRightPanel/CcamForm/index.tsx

View workflow job for this annotation

GitHub Actions / test

React Hook useEffect has missing dependencies: 'criteriaData' and 'currentCriteria'. Either include them or remove the dependency array. You can also do a functional update 'setCurrentCriteria(c => ...)' if you only need 'currentCriteria' in the 'setCurrentCriteria' call

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import KeyboardBackspaceIcon from '@mui/icons-material/KeyboardBackspace'

import useStyles from '../formStyles'
import { CriteriaDrawerComponentProps } from 'types'
import { Cim10DataType, Comparators, CriteriaType } from 'types/requestCriterias'
import { Cim10DataType, Comparators, CriteriaDataKey, CriteriaType } from 'types/requestCriterias'
import { BlockWrapper } from 'components/ui/Layout'
import OccurenceInput from 'components/ui/Inputs/Occurences'
import AdvancedInputs from '../AdvancedInputs'
Expand All @@ -28,6 +28,7 @@ import { getConfig } from 'config'
import ValueSetField from 'components/SearchValueSet/ValueSetField'
import { getValueSetsFromSystems } from 'utils/valueSets'
import { LabelObject } from 'types/searchCriterias'
import { mappingCriteria } from '../DemographicForm'

enum Error {
ADVANCED_INPUTS_ERROR,
Expand Down Expand Up @@ -83,7 +84,9 @@ const Cim10Form = (props: CriteriaDrawerComponentProps) => {
)
)
.filter((e) => e)
setCurrentCriteria({ ...currentCriteria, code: foundCodes })
const encounterStatus =
mappingCriteria(currentCriteria?.encounterStatus, CriteriaDataKey.ENCOUNTER_STATUS, criteriaData) || []
setCurrentCriteria({ ...currentCriteria, code: foundCodes, encounterStatus })
}, [])

Check warning on line 90 in src/components/CreationCohort/DiagramView/components/LogicalOperator/components/CriteriaRightPanel/Cim10Form/index.tsx

View workflow job for this annotation

GitHub Actions / test

React Hook useEffect has missing dependencies: 'criteriaData' and 'currentCriteria'. Either include them or remove the dependency array. You can also do a functional update 'setCurrentCriteria(c => ...)' if you only need 'currentCriteria' in the 'setCurrentCriteria' call
return (
<Grid className={classes.root}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,13 @@ import { useDebounce } from 'utils/debounce'
import { SearchByTypes, FilterByDocumentStatus } from 'types/searchCriterias'
import { IndeterminateCheckBoxOutlined } from '@mui/icons-material'
import { SearchInputError } from 'types/error'
import { Comparators, DocumentDataType, CriteriaType } from 'types/requestCriterias'
import { Comparators, DocumentDataType, CriteriaType, CriteriaDataKey } from 'types/requestCriterias'
import Searchbar from 'components/ui/Searchbar'
import SearchInput from 'components/ui/Searchbar/SearchInput'
import { BlockWrapper } from 'components/ui/Layout'
import OccurenceInput from 'components/ui/Inputs/Occurences'
import { SourceType } from 'types/scope'
import { mappingCriteria } from '../DemographicForm'

const defaultComposition: Omit<DocumentDataType, 'id'> = {
type: CriteriaType.DOCUMENTS,
Expand Down Expand Up @@ -290,7 +291,7 @@ const DocumentsForm: React.FC<CriteriaDrawerComponentProps> = (props) => {
noOptionsText="Veuillez entrer un statut de visite associée"
getOptionLabel={(option) => option.label}
isOptionEqualToValue={(option, value) => option.id === value.id}
value={defaultValues.encounterStatus}
value={mappingCriteria(defaultValues?.encounterStatus, CriteriaDataKey.ENCOUNTER_STATUS, criteriaData)}
onChange={(e, value) => _onChangeValue('encounterStatus', value)}
renderInput={(params) => <TextField {...params} label="Statut de la visite associée" />}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {

import useStyles from '../formStyles'
import { CriteriaDrawerComponentProps } from 'types'
import { Comparators, GhmDataType, CriteriaType } from 'types/requestCriterias'
import { Comparators, GhmDataType, CriteriaType, CriteriaDataKey } from 'types/requestCriterias'
import KeyboardBackspaceIcon from '@mui/icons-material/KeyboardBackspace'
import { BlockWrapper } from 'components/ui/Layout'
import OccurenceInput from 'components/ui/Inputs/Occurences'
Expand All @@ -24,6 +24,7 @@ import { SourceType } from 'types/scope'
import ValueSetField from 'components/SearchValueSet/ValueSetField'
import { getConfig } from 'config'
import { getValueSetsFromSystems } from 'utils/valueSets'
import { mappingCriteria } from '../DemographicForm'

enum Error {
ADVANCED_INPUTS_ERROR,
Expand Down Expand Up @@ -63,7 +64,9 @@ const GhmForm = (props: CriteriaDrawerComponentProps) => {
criteriaData.data.ghmData.find((cacheCode: any) => cacheCode.id === code.id && cacheCode.system === code.system)
)
.filter((e) => e)
setCurrentCriteria({ ...currentCriteria, code: foundCodes })
const encounterStatus =
mappingCriteria(currentCriteria?.encounterStatus, CriteriaDataKey.ENCOUNTER_STATUS, criteriaData) || []
setCurrentCriteria({ ...currentCriteria, code: foundCodes, encounterStatus })
}, [])

return (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useEffect, useMemo, useState } from 'react'

import { CriteriaDrawerComponentProps } from 'types'
import { Comparators, MedicationDataType, CriteriaType } from 'types/requestCriterias'
import { Comparators, MedicationDataType, CriteriaType, CriteriaDataKey } from 'types/requestCriterias'
import {
Grid,
IconButton,
Expand All @@ -27,6 +27,7 @@ import AdvancedInputs from '../AdvancedInputs'
import KeyboardBackspaceIcon from '@mui/icons-material/KeyboardBackspace'
import { getValueSetsFromSystems } from 'utils/valueSets'
import { LabelObject } from 'types/searchCriterias'
import { mappingCriteria } from '../DemographicForm'

enum Error {
ADVANCED_INPUTS_ERROR,
Expand Down Expand Up @@ -77,7 +78,10 @@ const MedicationForm = (props: CriteriaDrawerComponentProps) => {
)
)
.filter((e) => e)
setCurrentCriteria({ ...currentCriteria, code: foundCodes })
.filter((e) => e)
const encounterStatus =
mappingCriteria(currentCriteria?.encounterStatus, CriteriaDataKey.ENCOUNTER_STATUS, criteriaData) || []
setCurrentCriteria({ ...currentCriteria, code: foundCodes, encounterStatus })
}, [])

if (criteriaData?.data?.prescriptionTypes === 'loading' || criteriaData?.data?.administrations === 'loading') {
Expand Down
12 changes: 6 additions & 6 deletions src/utils/mappers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,13 @@ export const buildLabelObjectFilter = (criterion: LabelObject[] | undefined | nu
}

export const unbuildLabelObjectFilter = (currentCriterion: any, filterName: string, values?: string | null) => {
const valuesIds = values?.split(',') || []
const newArray = valuesIds?.map((url) => ({
system: url.split('|')?.[0],
id: url.split('|')?.[1]
}))
if (newArray)
const valuesIds = values?.split(',') || []

Check failure on line 62 in src/utils/mappers.ts

View workflow job for this annotation

GitHub Actions / test

Insert `·`
const newArray = valuesIds?.map((value) =>
value.includes('|') ? { system: value.split('|')?.[0], id: value.split('|')?.[1] } : { id: value }
)
if (newArray) {
currentCriterion[filterName] = currentCriterion ? [...currentCriterion[filterName], ...newArray] : newArray
}
}

export const buildEncounterServiceFilter = (criterion?: LabelObject[]) => {
Expand Down

0 comments on commit ab562bc

Please sign in to comment.