Skip to content

Commit

Permalink
fix:fix mater - Ref gestion-de-projet#2535, Ref gestion-de-projet#2415
Browse files Browse the repository at this point in the history
* fix: put back executive units in mater forms - Ref gestion-de-projet#2535

* fix: fixed maternity forms criteria - Ref gestion-de-projet#2415

* fix: fixed maternity duplicates - Ref gestion-de-projet#2415

* fix: fixed typo in occurrences

* fix: fixed typo in temporal constraints - Ref gestion-de-projet#2415
  • Loading branch information
ManelleG authored Mar 27, 2024
1 parent 4ae1081 commit 0437cdb
Show file tree
Hide file tree
Showing 9 changed files with 62 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ const HospitForm = ({
onChangeIsInclusive={setIsInclusive}
infoAlert={['Tous les éléments des champs multiples sont liés par une contrainte OU']}
errorAlert={[
error === Error.EMPTY_FORM ? "Merci de renseigner au moins un nombre d'occurence supérieur ou égal à 1" : ''
error === Error.EMPTY_FORM ? "Merci de renseigner au moins un nombre d'occurrence supérieur ou égal à 1" : ''
]}
>
<BlockWrapper className={classes.inputItem}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,16 @@ const PregnantForm = ({
criteria?.pregnancyStartDate || null
)
const [pregnancyEndDate, setPregnancyEndDate] = useState<string | null | undefined>(
criteria?.pregnancyStartDate || null
criteria?.pregnancyEndDate || null
)
const [pregnancyMode, setPregnancyMode] = useState<LabelObject[]>(
mappingCriteria(criteria?.pregnancyMode, CriteriaDataKey.PREGNANCY_MODE, criteriaData) || []
)
const [foetus, setFoetus] = useState<number>(criteria?.foetus || 1)
const [foetus, setFoetus] = useState<number>(criteria?.foetus || 0)
const [foetusComparator, setFoetusComparator] = useState<Comparators>(
criteria?.foetusComparator || Comparators.GREATER_OR_EQUAL
)
const [parity, setParity] = useState<number>(criteria?.parity || 1)
const [parity, setParity] = useState<number>(criteria?.parity || 0)
const [parityComparator, setParityComparator] = useState<Comparators>(
criteria?.parityComparator || Comparators.GREATER_OR_EQUAL
)
Expand Down Expand Up @@ -155,7 +155,7 @@ const PregnantForm = ({
onChangeIsInclusive={setIsInclusive}
infoAlert={['Tous les éléments des champs multiples sont liés par une contrainte OU']}
errorAlert={[
error === Error.EMPTY_FORM ? "Merci de renseigner au moins un nombre d'occurence supérieur ou égal à 1" : ''
error === Error.EMPTY_FORM ? "Merci de renseigner au moins un nombre d'occurrence supérieur ou égal à 1" : ''
]}
>
<BlockWrapper className={classes.inputItem}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const StayConstraints: React.FC<StayConstraintsProps> = ({ constraints, onChange
const temporalConstraintsTypes = [
{
id: TemporalConstraintsKind.NONE,
label: 'Aucune contrainte sur les épisodes'
label: 'Aucune contrainte sur les séjours'
},
{
id: TemporalConstraintsKind.SAME_ENCOUNTER,
Expand Down
30 changes: 26 additions & 4 deletions src/components/Patient/PatientForms/MaternityForms/HospitCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,39 @@ import { hospitForm } from 'data/hospitData'
import moment from 'moment'
import FormCards from 'components/ui/FormCard'
import DomainAdd from '@mui/icons-material/DomainAdd'
import { QuestionnaireResponse, QuestionnaireResponseItemAnswer } from 'fhir/r4'
interface HospitCardProps {
form: CohortQuestionnaireResponse
}

const HospitCard: React.FC<HospitCardProps> = ({ form }) => {
const getBirthDeliveryDate = (
form: QuestionnaireResponse,
hospitForm: {
[key: string]: {
id: string
type: keyof QuestionnaireResponseItemAnswer
}
}
) => {
const item = form.item?.find((item) => item.linkId === hospitForm.birthDeliveryStartDate.id)
return item ? `Accouchement le ${getDataFromForm(form, hospitForm.birthDeliveryStartDate)}` : undefined
}

const formatHospitalisationDates = (start?: string, end?: string) => {
if (start && end) {
return `Hospitalisation du ${moment(start).format('DD/MM/YYYY')} au ${moment(end).format('DD/MM/YYYY')}`
} else if (start && !end) {
return `Début d'hospitalisation le ${moment(start).format('DD/MM/YYYY')}`
}
}

const hospitChipData = [
form.item?.find((item) => item.linkId === hospitForm.birthDeliveryStartDate.id)
? `Accouchement le ${getDataFromForm(form, hospitForm.birthDeliveryStartDate)}`
: `Date d'écriture : ${moment(form.authored).format('DD/MM/YYYY')}`,
getBirthDeliveryDate(form, hospitForm),
formatHospitalisationDates(form.hospitDates?.start, form.hospitDates?.end),
`Unité exécutrice : ${form.serviceProvider}`
]
].filter((item): item is string => item !== undefined)

const hospitDetails = [
{
name: "Motif d'hospitalisation",
Expand Down
2 changes: 1 addition & 1 deletion src/services/aphp/callApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -893,7 +893,7 @@ type fetchFormsProps = {
}
export const fetchForms = async (args: fetchFormsProps) => {
const { patient, formName, _list, startDate, endDate, executiveUnits } = args
let options: string[] = []
let options: string[] = ['status=in-progress,completed']
if (patient) options = [...options, `subject=${patient}`]
if (formName) options = [...options, `questionnaire.name=${formName}`]
if (_list && _list.length > 0) options = [...options, `_list=${_list.reduce(paramValuesReducer)}`]
Expand Down
10 changes: 10 additions & 0 deletions src/state/patient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1435,13 +1435,15 @@ function linkElementWithEncounter<
serviceProvider?: string
NDA?: string
documents?: any[]
hospitDates?: string[]
})[] = []

for (const entry of elementEntries) {
let newElement = entry as T & {
serviceProvider?: string
NDA?: string
documents?: any[]
hospitDates?: string[]
}

let encounterId = ''
Expand Down Expand Up @@ -1469,6 +1471,9 @@ function linkElementWithEncounter<
case RessourceType.IMAGING:
encounterId = (entry as ImagingStudy).encounter?.reference?.replace(/^Encounter\//, '') ?? ''
break
case RessourceType.QUESTIONNAIRE_RESPONSE:
encounterId = entry.encounter?.reference?.replace(/^Encounter\//, '') ?? ''
break
}

const foundEncounter = encounterList.find(({ id }) => id === encounterId) || null
Expand Down Expand Up @@ -1506,6 +1511,7 @@ function fillElementInformation<
serviceProvider?: string
NDA?: string
documents?: any[]
hospitDates?: string[]
}

const encounterIsDetailed = encounter?.id !== encounterId
Expand All @@ -1532,5 +1538,9 @@ function fillElementInformation<
newElement.documents = encounter.documents
}

if (resourceType === RessourceType.QUESTIONNAIRE_RESPONSE) {
newElement.hospitDates = encounter.period
}

return newElement
}
2 changes: 2 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
OperationOutcome,
Parameters,
Patient,
Period,
Procedure,
QuestionnaireResponse,
Resource
Expand Down Expand Up @@ -657,6 +658,7 @@ export enum BiologyStatus {
export type CohortQuestionnaireResponse = QuestionnaireResponse & {
serviceProvider?: string
NDA?: string
hospitDates?: Period
}

export type CohortObservation = Observation & {
Expand Down
24 changes: 14 additions & 10 deletions src/utils/cohortCreation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,7 @@ const constructFilterFhir = (criterion: SelectedCriteriaType, deidentified: bool
filterFhir = [
'subject.active=true',
`questionnaire.name=${FormNames.PREGNANCY}`,
'status=in-progress,completed',
questionnaireFiltersBuilders(
pregnancyForm.pregnancyStartDate,
buildDateFilter(criterion.pregnancyStartDate, 'ge', true)
Expand Down Expand Up @@ -468,6 +469,7 @@ const constructFilterFhir = (criterion: SelectedCriteriaType, deidentified: bool
filterFhir = [
'subject.active=true',
`questionnaire.name=${FormNames.HOSPIT}`,
'status=in-progress,completed',
questionnaireFiltersBuilders(hospitForm.hospitReason, buildSearchFilter(criterion.hospitReason)),
questionnaireFiltersBuilders(hospitForm.inUteroTransfer, buildLabelObjectFilter(criterion.inUteroTransfer)),
questionnaireFiltersBuilders(
Expand Down Expand Up @@ -1386,9 +1388,9 @@ export async function unbuildRequest(_json: string): Promise<any> {
currentCriterion.pregnancyStartDate = null
currentCriterion.pregnancyEndDate = null
currentCriterion.pregnancyMode = []
currentCriterion.foetus = 1
currentCriterion.foetus = 0
currentCriterion.foetusComparator = Comparators.GREATER_OR_EQUAL
currentCriterion.parity = 1
currentCriterion.parity = 0
currentCriterion.parityComparator = Comparators.GREATER_OR_EQUAL
currentCriterion.maternalRisks = []
currentCriterion.maternalRisksPrecision = ''
Expand All @@ -1411,10 +1413,11 @@ export async function unbuildRequest(_json: string): Promise<any> {

switch (key) {
case pregnancyForm.pregnancyStartDate.id:
currentCriterion.pregnancyStartDate = unbuildDateFilter(singleValue)
break
case pregnancyForm.pregnancyEndDate.id:
currentCriterion.pregnancyEndDate = unbuildDateFilter(singleValue)
if (operator?.includes('ge')) {
currentCriterion.pregnancyStartDate = unbuildDateFilter(singleValue)
} else if (operator === 'le') {
currentCriterion.pregnancyEndDate = unbuildDateFilter(singleValue)
}
break
case pregnancyForm.pregnancyMode.id:
unbuildLabelObjectFilter(currentCriterion, 'pregnancyMode', joinedValues)
Expand Down Expand Up @@ -1587,10 +1590,11 @@ export async function unbuildRequest(_json: string): Promise<any> {
unbuildLabelObjectFilter(currentCriterion, 'analgesieType', joinedValues)
break
case hospitForm.birthDeliveryStartDate.id:
currentCriterion.birthDeliveryStartDate = unbuildDateFilter(singleValue)
break
case hospitForm.birthDeliveryEndDate.id:
currentCriterion.birthDeliveryEndDate = unbuildDateFilter(singleValue)
if (operator?.includes('ge')) {
currentCriterion.birthDeliveryStartDate = unbuildDateFilter(singleValue)
} else if (operator === 'le') {
currentCriterion.birthDeliveryEndDate = unbuildDateFilter(singleValue)
}
break
case hospitForm.birthDeliveryWeeks.id: {
const _value = `${operator}${singleValue}`
Expand Down
6 changes: 3 additions & 3 deletions src/utils/requestCriterias.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -378,11 +378,11 @@ export const criteriasAsArray = (selectedCriteria: SelectedCriteriaType, criteri
)
)
}
if (!isNaN(selectedCriteria.foetus) && selectedCriteria.foetusComparator)
if (!isNaN(selectedCriteria.foetus) && selectedCriteria.foetusComparator && selectedCriteria.foetus !== 0)
labels.push(
getNbOccurencesLabel(selectedCriteria.foetus, selectedCriteria.foetusComparator, 'Nombre de foetus')
)
if (!isNaN(selectedCriteria.parity) && selectedCriteria.parityComparator)
if (!isNaN(selectedCriteria.parity) && selectedCriteria.parityComparator && selectedCriteria.parity !== 0)
labels.push(getNbOccurencesLabel(selectedCriteria.parity, selectedCriteria.parityComparator, 'Parité'))
if (selectedCriteria.maternalRisks && selectedCriteria.maternalRisks.length > 0)
labels.push(
Expand Down Expand Up @@ -859,7 +859,7 @@ export const criteriasAsArray = (selectedCriteria: SelectedCriteriaType, criteri
getNbOccurencesLabel(
selectedCriteria.occurrence,
selectedCriteria.occurrenceComparator,
"Nombre d'occurences"
"Nombre d'occurrences"
)
)
if (selectedCriteria.startOccurrence || selectedCriteria.endOccurrence)
Expand Down

0 comments on commit 0437cdb

Please sign in to comment.