-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add test for checkNominativeCriteria into `utils/cohortCreation…
….ts` - Ref gestion-de-projet#2708 (#1033) * test: add test for checkNominativeCriteria into `utils/cohortCreation.ts` - Ref gestion-de-projet#2708
- Loading branch information
1 parent
2240e1e
commit 00a618a
Showing
7 changed files
with
5,909 additions
and
2,183 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,226 @@ | ||
import { CriteriaType, SelectedCriteriaType } from 'types/requestCriterias' | ||
|
||
const defaultProcedureCriteria: SelectedCriteriaType = { | ||
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 | ||
} | ||
|
||
const defaultPatientCriteria: SelectedCriteriaType = { | ||
id: 1, | ||
title: 'Patient', | ||
type: CriteriaType.PATIENT, | ||
genders: [], | ||
vitalStatus: [], | ||
age: [null, null], | ||
birthdates: [null, null], | ||
deathDates: [null, null] | ||
} | ||
|
||
const defaultEncounterCriteria: SelectedCriteriaType = { | ||
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 | ||
} | ||
|
||
const defaultIPPCriteria: SelectedCriteriaType = { | ||
id: 1, | ||
type: CriteriaType.IPP_LIST, | ||
isInclusive: true, | ||
title: 'critere IPP', | ||
search: '' | ||
} | ||
|
||
export const procedurePeudonimizedCriteria: SelectedCriteriaType[] = [ | ||
{ | ||
...defaultProcedureCriteria, | ||
startOccurrence: ['2024-08-15', '2024-08-22'], | ||
encounterStartDate: ['2024-08-07', '2024-08-21'], | ||
encounterStatus: [ | ||
{ | ||
id: 'cancelled', | ||
label: 'Cancelled', | ||
system: 'http://hl7.org/fhir/CodeSystem/encounter-status' | ||
} | ||
], | ||
encounterEndDate: ['2024-08-22', '2024-08-22'], | ||
code: [ | ||
{ | ||
id: '000212', | ||
label: "000212 - Actes Diagnostiques Sur L'oreille", | ||
system: | ||
'https://www.atih.sante.fr/plateformes-de-transmission-et-logiciels/logiciels-espace-de-telechargement/id_lot/3550' | ||
}, | ||
{ | ||
id: '000489', | ||
label: '000489 - Actes Thérapeutiques Sur Les Vaisseaux Intracrâniens', | ||
system: | ||
'https://www.atih.sante.fr/plateformes-de-transmission-et-logiciels/logiciels-espace-de-telechargement/id_lot/3550' | ||
} | ||
] | ||
} | ||
] | ||
|
||
export const patientPseudonimizedCriteria: SelectedCriteriaType[] = [ | ||
{ | ||
...defaultPatientCriteria, | ||
genders: [ | ||
{ | ||
id: 'f', | ||
label: 'Femme' | ||
} | ||
], | ||
vitalStatus: [ | ||
{ | ||
id: 'alive', | ||
label: 'Vivant' | ||
} | ||
] | ||
} | ||
] | ||
|
||
export const patientPseudonimizedAgeCriteria: SelectedCriteriaType[] = [ | ||
{ | ||
...defaultPatientCriteria, | ||
age: ['0/2/12', '0/5/15'] | ||
} | ||
] | ||
|
||
export const patientNominativeAge0Criteria: SelectedCriteriaType[] = [ | ||
{ | ||
...defaultPatientCriteria, | ||
age: ['7/2/12', '0/5/15'] | ||
} | ||
] | ||
|
||
export const patientNominativeAge1Criteria: SelectedCriteriaType[] = [ | ||
{ | ||
...defaultPatientCriteria, | ||
age: ['0/2/12', '8/5/15'] | ||
} | ||
] | ||
|
||
export const patientNominativeBirthdates: SelectedCriteriaType[] = [ | ||
{ | ||
...defaultPatientCriteria, | ||
birthdates: ['2024-08-15', '2024-08-15'] | ||
} | ||
] | ||
|
||
export const patientNominativeDeathDates: SelectedCriteriaType[] = [ | ||
{ | ||
...defaultPatientCriteria, | ||
deathDates: ['2024-08-15', '2024-08-15'] | ||
} | ||
] | ||
|
||
export const criteriasArrayWtihNominativeData: SelectedCriteriaType[] = [ | ||
...procedurePeudonimizedCriteria, | ||
{ | ||
...defaultPatientCriteria, | ||
genders: [ | ||
{ | ||
id: 'f', | ||
label: 'Femme' | ||
} | ||
], | ||
vitalStatus: [ | ||
{ | ||
id: 'alive', | ||
label: 'Vivant' | ||
} | ||
], | ||
deathDates: ['2024-08-15', '2024-08-15'] | ||
} | ||
] | ||
|
||
export const criteriaArrayWithNoNominativeData: SelectedCriteriaType[] = [ | ||
...procedurePeudonimizedCriteria, | ||
{ | ||
...defaultPatientCriteria, | ||
genders: [ | ||
{ | ||
id: 'f', | ||
label: 'Femme' | ||
} | ||
], | ||
vitalStatus: [ | ||
{ | ||
id: 'alive', | ||
label: 'Vivant' | ||
} | ||
], | ||
age: ['0/1/2', '0/5/15'] | ||
} | ||
] | ||
|
||
export const ippNominativeCriteria: SelectedCriteriaType[] = [ | ||
{ | ||
...defaultIPPCriteria, | ||
search: '800000000, 800000001,8514257145' | ||
} | ||
] | ||
|
||
export const ippEmptyCriteria: SelectedCriteriaType[] = [ | ||
{ | ||
...defaultIPPCriteria | ||
} | ||
] | ||
|
||
export const encounterPseudonimizedCriteria: SelectedCriteriaType[] = [ | ||
{ | ||
...defaultEncounterCriteria | ||
} | ||
] | ||
|
||
export const encounterPseudoAgeCriteria: SelectedCriteriaType[] = [ | ||
{ | ||
...defaultEncounterCriteria, | ||
age: ['0/1/2', '0/5/15'] | ||
} | ||
] | ||
|
||
export const encounterNominativeAgeCriteria: SelectedCriteriaType[] = [ | ||
{ | ||
...defaultEncounterCriteria, | ||
age: ['2/1/2', '5/5/15'] | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
import { SelectedCriteriaType } from 'types/requestCriterias' | ||
import { | ||
procedurePeudonimizedCriteria, | ||
ippNominativeCriteria, | ||
ippEmptyCriteria, | ||
encounterPseudonimizedCriteria, | ||
encounterPseudoAgeCriteria, | ||
encounterNominativeAgeCriteria, | ||
patientPseudonimizedCriteria, | ||
patientPseudonimizedAgeCriteria, | ||
patientNominativeAge0Criteria, | ||
patientNominativeAge1Criteria, | ||
patientNominativeBirthdates, | ||
patientNominativeDeathDates, | ||
criteriasArrayWtihNominativeData, | ||
criteriaArrayWithNoNominativeData | ||
} from '../__tests__/data/cohortCreation.' | ||
import { checkNominativeCriteria } from './cohortCreation' | ||
|
||
describe('test of checkNominativeCriteria', () => { | ||
it('should return false if selectedCriteria is an empty array', () => { | ||
const selectedCriteria: SelectedCriteriaType[] = [] | ||
expect(checkNominativeCriteria(selectedCriteria)).toBe(false) | ||
}) | ||
it("should return false if selectedCriteria contain procedure pseudonimized criteria", () => { | ||
const selectedCriteria: SelectedCriteriaType[] = procedurePeudonimizedCriteria | ||
console.log('procedurePeudonimizedCriteria', procedurePeudonimizedCriteria[0]) | ||
expect(checkNominativeCriteria(selectedCriteria)).toBe(false) | ||
}) | ||
it("should return false if selectedCriteria contain patient pseudonimized criteria", () => { | ||
const selectedCriteria: SelectedCriteriaType[] = patientPseudonimizedCriteria | ||
expect(checkNominativeCriteria(selectedCriteria)).toBe(false) | ||
}) | ||
it("should return false if selectedCriteria contains patient.age pseudonimized", () => { | ||
const selectedCriteria: SelectedCriteriaType[] = patientPseudonimizedAgeCriteria | ||
expect(checkNominativeCriteria(selectedCriteria)).toBe(false) | ||
}) | ||
it("should return true if selectedCriteria contain patient.age[0] nominative", () => { | ||
const selectedCriteria: SelectedCriteriaType[] = patientNominativeAge0Criteria | ||
expect(checkNominativeCriteria(selectedCriteria)).toBe(true) | ||
}) | ||
it("should return true if selectedCriteria contain patient.age[1] nominative", () => { | ||
const selectedCriteria: SelectedCriteriaType[] = patientNominativeAge1Criteria | ||
expect(checkNominativeCriteria(selectedCriteria)).toBe(true) | ||
}) | ||
it('should return true if selectedCriteria contains a patient birthdates', () => { | ||
const selectedCriteria: SelectedCriteriaType[] = patientNominativeBirthdates | ||
expect(checkNominativeCriteria(selectedCriteria)).toBe(true) | ||
}) | ||
it('should return true if selectedCriteria contains a patient deathDates', () => { | ||
const selectedCriteria: SelectedCriteriaType[] = patientNominativeDeathDates | ||
expect(checkNominativeCriteria(selectedCriteria)).toBe(true) | ||
}) | ||
it('should return true if selectedCriteria contains a nominative criteria', () => { | ||
const selectedCriteria: SelectedCriteriaType[] = criteriasArrayWtihNominativeData | ||
console.log('selectedCriteria', selectedCriteria[0], selectedCriteria[1]) | ||
expect(checkNominativeCriteria(selectedCriteria)).toBe(true) | ||
}) | ||
it("should return false if selectedCriteria doesn't contains a nominative criteria", () => { | ||
const selectedCriteria: SelectedCriteriaType[] = criteriaArrayWithNoNominativeData | ||
expect(checkNominativeCriteria(selectedCriteria)).toBe(false) | ||
}) | ||
it('should return true if selectedCriteria contains a nominative IPP.search', () => { | ||
const selectedCriteria: SelectedCriteriaType[] = ippNominativeCriteria | ||
expect(checkNominativeCriteria(selectedCriteria)).toBe(true) | ||
}) | ||
it('should return true if selectedCriteria contains an IPP criteria', () => { | ||
const selectedCriteria: SelectedCriteriaType[] = ippEmptyCriteria | ||
expect(checkNominativeCriteria(selectedCriteria)).toBe(true) | ||
}) | ||
it('should return false if selectedCriteria contains an encounter pseudonimized criteria', () => { | ||
const selectedCriteria: SelectedCriteriaType[] = encounterPseudonimizedCriteria | ||
expect(checkNominativeCriteria(selectedCriteria)).toBe(false) | ||
}) | ||
it('should return false if selectedCriteria contains a peudonimize encounter.age', () => { | ||
const selectedCriteria: SelectedCriteriaType[] = encounterPseudoAgeCriteria | ||
expect(checkNominativeCriteria(selectedCriteria)).toBe(false) | ||
}) | ||
it('should return true if selectedCriteria contains a nominative encounter.age', () => { | ||
const selectedCriteria: SelectedCriteriaType[] = encounterNominativeAgeCriteria | ||
expect(checkNominativeCriteria(selectedCriteria)).toBe(true) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters