Skip to content

Commit

Permalink
feat: add criteria form builder
Browse files Browse the repository at this point in the history
  • Loading branch information
pl-buiquang committed Oct 8, 2024
1 parent f5ba191 commit 8711f5c
Show file tree
Hide file tree
Showing 90 changed files with 5,379 additions and 8,820 deletions.
2 changes: 1 addition & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
}
],
"max-statements": [
1, {
0, {
"max": 30
}
],
Expand Down
129 changes: 67 additions & 62 deletions src/__tests__/cohortCreation/cohortCreation.test.ts

Large diffs are not rendered by default.

33 changes: 10 additions & 23 deletions src/__tests__/data/cohortCreation/claimCriteria.ts
Original file line number Diff line number Diff line change
@@ -1,33 +1,20 @@
import { GhmDataType, Comparators, CriteriaType } from 'types/requestCriterias'
import {
GhmDataType,
form
} from 'components/CreationCohort/DiagramView/components/LogicalOperator/components/CriteriaRightPanel/forms/GHMForm'
import { Comparators } from 'types/requestCriterias'

export const defaultClaimCriteria: GhmDataType = {
id: 1,
type: CriteriaType.CLAIM,
isInclusive: true,
title: 'Claim',
occurrence: null,
occurrenceComparator: null,
startOccurrence: [null, null],
endOccurrence: [null, null],
encounterStartDate: [null, null],
includeEncounterStartDateNull: false,
encounterEndDate: [null, null],
includeEncounterEndDateNull: false,
encounterStatus: [],
code: [],
label: undefined,
encounterService: undefined
...form().initialData
}

export const completeClaimCriteria: GhmDataType = {
...defaultClaimCriteria,
occurrence: 1,
occurrenceComparator: Comparators.GREATER,
startOccurrence: ['2024-09-03', '2024-09-04'],
encounterStartDate: ['2024-09-04', '2024-09-07'],
includeEncounterStartDateNull: true,
encounterEndDate: ['2024-09-02', '2024-09-06'],
includeEncounterEndDateNull: false,
occurrence: { value: 1, comparator: Comparators.GREATER },
startOccurrence: { start: '2024-09-03', end: '2024-09-04' },
encounterStartDate: { start: '2024-09-04', end: '2024-09-07', includeNull: true },
encounterEndDate: { start: '2024-09-02', end: '2024-09-06' },
encounterStatus: [{ id: 'cancelled', label: 'Cancelled', system: 'http://hl7.org/fhir/CodeSystem/encounter-status' }],
code: [
{
Expand Down
109 changes: 38 additions & 71 deletions src/__tests__/data/cohortCreation/cohortCreation.ts
Original file line number Diff line number Diff line change
@@ -1,87 +1,54 @@
import { CriteriaType, SelectedCriteriaType } from 'types/requestCriterias'

const defaultProcedureCriteria: SelectedCriteriaType = {
import {
CcamDataType,
form as ccamForm
} from 'components/CreationCohort/DiagramView/components/LogicalOperator/components/CriteriaRightPanel/forms/CCAMForm'
import {
DemographicDataType,
form as demographicForm
} from 'components/CreationCohort/DiagramView/components/LogicalOperator/components/CriteriaRightPanel/forms/DemographicForm'
import {
EncounterDataType,
form as encounterForm
} from 'components/CreationCohort/DiagramView/components/LogicalOperator/components/CriteriaRightPanel/forms/EncounterForm'
import {
IPPListDataType,
form as ippForm
} from 'components/CreationCohort/DiagramView/components/LogicalOperator/components/CriteriaRightPanel/forms/IPPForm'
import { SelectedCriteriaType } from 'types/requestCriterias'

const defaultProcedureCriteria: CcamDataType = {
id: 1,
error: undefined,
type: CriteriaType.PROCEDURE,
encounterService: undefined,
isInclusive: true,
title: 'Procedure',
occurrence: null,
occurrenceComparator: null,
startOccurrence: [null, null],
endOccurrence: undefined,
encounterStartDate: [null, null],
includeEncounterStartDateNull: true,
encounterEndDate: [null, null],
includeEncounterEndDateNull: true,
encounterStatus: [],
hierarchy: undefined,
code: [],
source: null,
label: undefined
...ccamForm().initialData
}

const defaultPatientCriteria: SelectedCriteriaType = {
const defaultPatientCriteria: DemographicDataType = {
id: 1,
title: 'Patient',
type: CriteriaType.PATIENT,
genders: [],
vitalStatus: [],
age: [null, null],
birthdates: [null, null],
deathDates: [null, null]
...demographicForm().initialData
}

const defaultEncounterCriteria: SelectedCriteriaType = {
const defaultEncounterCriteria: EncounterDataType = {
id: 1,
type: CriteriaType.ENCOUNTER,
isInclusive: true,
title: 'critere encouter',
occurrence: null,
occurrenceComparator: null,
startOccurrence: [null, null],
endOccurrence: [null, null],
encounterStartDate: [null, null],
includeEncounterStartDateNull: false,
encounterEndDate: [null, null],
includeEncounterEndDateNull: false,
encounterStatus: [],
age: [null, null],
duration: [null, null],
admissionMode: null,
entryMode: null,
exitMode: null,
priseEnChargeType: null,
typeDeSejour: null,
reason: null,
destination: null,
provenance: null,
admission: null,
encounterService: undefined
...encounterForm().initialData
}

const defaultIPPCriteria: SelectedCriteriaType = {
const defaultIPPCriteria: IPPListDataType = {
id: 1,
type: CriteriaType.IPP_LIST,
isInclusive: true,
title: 'critere IPP',
search: ''
...ippForm().initialData
}

export const procedurePeudonimizedCriteria: SelectedCriteriaType[] = [
{
...defaultProcedureCriteria,
startOccurrence: ['2024-08-15', '2024-08-22'],
encounterStartDate: ['2024-08-07', '2024-08-21'],
startOccurrence: { start: '2024-08-15', end: '2024-08-22' },
encounterStartDate: { start: '2024-08-07', end: '2024-08-21' },
encounterStatus: [
{
id: 'cancelled',
label: 'Cancelled',
system: 'http://hl7.org/fhir/CodeSystem/encounter-status'
}
],
encounterEndDate: ['2024-08-22', '2024-08-22'],
encounterEndDate: { start: '2024-08-22', end: '2024-08-22' },
code: [
{
id: '000212',
Expand Down Expand Up @@ -120,35 +87,35 @@ export const patientPseudonimizedCriteria: SelectedCriteriaType[] = [
export const patientPseudonimizedAgeCriteria: SelectedCriteriaType[] = [
{
...defaultPatientCriteria,
age: ['0/2/12', '0/5/15']
age: { start: '0/2/12', end: '0/5/15' }
}
]

export const patientNominativeAge0Criteria: SelectedCriteriaType[] = [
{
...defaultPatientCriteria,
age: ['7/2/12', '0/5/15']
age: { start: '7/2/12', end: '0/5/15' }
}
]

export const patientNominativeAge1Criteria: SelectedCriteriaType[] = [
{
...defaultPatientCriteria,
age: ['0/2/12', '8/5/15']
age: { start: '0/2/12', end: '8/5/15' }
}
]

export const patientNominativeBirthdates: SelectedCriteriaType[] = [
{
...defaultPatientCriteria,
birthdates: ['2024-08-15', '2024-08-15']
birthdates: { start: '2024-08-15', end: '2024-08-15' }
}
]

export const patientNominativeDeathDates: SelectedCriteriaType[] = [
{
...defaultPatientCriteria,
deathDates: ['2024-08-15', '2024-08-15']
deathDates: { start: '2024-08-15', end: '2024-08-15' }
}
]

Expand All @@ -168,7 +135,7 @@ export const criteriasArrayWtihNominativeData: SelectedCriteriaType[] = [
label: 'Vivant'
}
],
deathDates: ['2024-08-15', '2024-08-15']
deathDates: { start: '2024-08-15', end: '2024-08-15' }
}
]

Expand All @@ -188,7 +155,7 @@ export const criteriaArrayWithNoNominativeData: SelectedCriteriaType[] = [
label: 'Vivant'
}
],
age: ['0/1/2', '0/5/15']
age: { start: '0/1/2', end: '0/5/15' }
}
]

Expand All @@ -214,13 +181,13 @@ export const encounterPseudonimizedCriteria: SelectedCriteriaType[] = [
export const encounterPseudoAgeCriteria: SelectedCriteriaType[] = [
{
...defaultEncounterCriteria,
age: ['0/1/2', '0/5/15']
age: { start: '0/1/2', end: '0/5/15' }
}
]

export const encounterNominativeAgeCriteria: SelectedCriteriaType[] = [
{
...defaultEncounterCriteria,
age: ['2/1/2', '5/5/15']
age: { start: '2/1/2', end: '5/5/15' }
}
]
34 changes: 10 additions & 24 deletions src/__tests__/data/cohortCreation/conditionCriteria.ts
Original file line number Diff line number Diff line change
@@ -1,34 +1,20 @@
import { Cim10DataType, Comparators, CriteriaType } from 'types/requestCriterias'
import {
Cim10DataType,
form
} from 'components/CreationCohort/DiagramView/components/LogicalOperator/components/CriteriaRightPanel/forms/Cim10Form'
import { Comparators } from 'types/requestCriterias'

export const defaultConditionCriteria: Cim10DataType = {
id: 1,
type: CriteriaType.CONDITION,
isInclusive: true,
title: 'Condition',
occurrence: null,
occurrenceComparator: null,
startOccurrence: [null, null],
endOccurrence: [null, null],
encounterStartDate: [null, null],
includeEncounterStartDateNull: false,
encounterEndDate: [null, null],
includeEncounterEndDateNull: false,
encounterStatus: [],
code: [],
source: null,
diagnosticType: null,
label: undefined
...form().initialData
}

export const completeConditionCriteria: Cim10DataType = {
...defaultConditionCriteria,
occurrence: 1,
occurrenceComparator: Comparators.GREATER,
startOccurrence: [null, null],
encounterStartDate: ['2024-09-05', '2024-09-05'],
includeEncounterStartDateNull: true,
encounterEndDate: ['2024-09-06', '2024-09-07'],
includeEncounterEndDateNull: false,
occurrence: { value: 1, comparator: Comparators.GREATER },
startOccurrence: { start: null, end: null },
encounterStartDate: { start: '2024-09-05', end: '2024-09-05', includeNull: true },
encounterEndDate: { start: '2024-09-06', end: '2024-09-07' },
encounterStatus: [{ id: 'finished', label: 'Finished', system: 'http://hl7.org/fhir/CodeSystem/encounter-status' }],
code: [
{
Expand Down
49 changes: 21 additions & 28 deletions src/__tests__/data/cohortCreation/documentCriteria.ts
Original file line number Diff line number Diff line change
@@ -1,39 +1,32 @@
import { Comparators, CriteriaType, DocumentDataType } from 'types/requestCriterias'
import { SearchByTypes } from 'types/searchCriterias'
import {
DocumentDataType,
form
} from 'components/CreationCohort/DiagramView/components/LogicalOperator/components/CriteriaRightPanel/forms/DocumentsForm'
import { Comparators } from 'types/requestCriterias'
import { DocumentStatuses, FilterByDocumentStatus, SearchByTypes } from 'types/searchCriterias'

export const defaultDocumentCriteria: DocumentDataType = {
id: 1,
type: CriteriaType.DOCUMENTS,
isInclusive: true,
title: 'Document',
occurrence: null,
occurrenceComparator: null,
startOccurrence: [null, null],
endOccurrence: [null, null],
encounterStartDate: [null, null],
includeEncounterStartDateNull: false,
encounterEndDate: [null, null],
includeEncounterEndDateNull: false,
encounterStatus: [],
docStatuses: [],
error: undefined,
docType: null,
search: '',
searchBy: SearchByTypes.TEXT,
encounterService: undefined
...form().initialData
}

export const completeDocumentCriteria: DocumentDataType = {
...defaultDocumentCriteria,
occurrence: 1,
occurrenceComparator: Comparators.GREATER,
startOccurrence: ['2024-09-02', '2024-09-04'],
encounterStartDate: ['2024-09-05', '2024-09-05'],
includeEncounterStartDateNull: true,
encounterEndDate: ['2024-09-06', '2024-09-07'],
includeEncounterEndDateNull: true,
occurrence: { value: 1, comparator: Comparators.GREATER },
startOccurrence: { start: '2024-09-02', end: '2024-09-04' },
encounterStartDate: { start: '2024-09-05', end: '2024-09-05', includeNull: true },
encounterEndDate: { start: '2024-09-06', end: '2024-09-07', includeNull: true },
encounterStatus: [{ id: 'cancelled', label: 'Cancelled', system: 'http://hl7.org/fhir/CodeSystem/encounter-status' }],
docStatuses: ['Validé', 'Non validé'],
docStatuses: [
{
id: DocumentStatuses.FINAL,
label: FilterByDocumentStatus.VALIDATED
},
{
id: DocumentStatuses.PRELIMINARY,
label: FilterByDocumentStatus.NOT_VALIDATED
}
],
docType: [
{ type: 'Comptes Rendus Hospitalisation', label: 'CR de Jour', code: 'crh-j' },
{ type: 'Comptes Rendus Hospitalisation', label: 'CRH Chirurgie', code: 'crh-chir' }
Expand Down
Loading

0 comments on commit 8711f5c

Please sign in to comment.