@vidal-community/vidal-web-components
Version:
Vidal Web Components
81 lines • 10.1 kB
JavaScript
import { assert } from '@open-wc/testing';
import { FullMedicationDispense } from '../model/full-medication-dispense';
import { Drug, DrugType } from '../model/drug';
import { Classifications } from '../model/classifications';
import { Classification } from '../model/classification';
import { buildTimelineData } from './build';
import { Group } from './group';
import { SubGroup } from './subgroup';
import { Point } from './point';
import { Link } from './link';
const marketStatus = '';
test('builds vis-timeline data', async () => {
const dispensation = new FullMedicationDispense(new Drug(41929, 3400956369553, 3400058, 'DOLIPRANE 1000 mg Cpr Plq/100', undefined, Number(undefined), DrugType.PACK, '', marketStatus, undefined, undefined), new Classifications(new Classification(2164, 'SYSTEME NERVEUX', 'SN', ''), new Classification(1502, 'PARACETAMOL', 'PARA', '')), [{ startDate: '2021-11-15', quantity: 5 }, { startDate: '2021-12-24' }], new Classifications(new Classification(269, 'Cancérologie - Hématologie', 'Cancérologie - Hématologie', ''), new Classification(1251, 'Progestatifs', 'Progestatifs', '')));
const [atcClasses, activePrinciples, prescriptionItems] = buildTimelineData([dispensation], 'ATC', 'molecule');
assert.lengthOf(atcClasses, 1);
assert.deepInclude(atcClasses[0], new Group(2164, 'SYSTEME NERVEUX', 1, 'systeme-nerveux', [
2164 + '-' + 1502,
]));
assert.lengthOf(activePrinciples, 1);
assert.deepInclude(activePrinciples[0], new SubGroup(2164 + '-' + 1502, 2164, 'PARACETAMOL', 2, 'systeme-nerveux'));
assert.lengthOf(prescriptionItems, 4);
assert.deepInclude(prescriptionItems[0], new Point('41929-1020038177', 2164 + '-' + 1502, '*', '<b><span>DOLIPRANE 1000 mg Cpr Plq/100</span></b><br><br>Début : 15/11/2021<br><span>Quantité : 5</span><br><br><span><small>CIP13 : 3400956369553</small></span><br><span><small>CIP : 3400058</small></span>', 'systeme-nerveux', '2021-11-15', 41929));
assert.deepInclude(prescriptionItems[1], new Point('41929-1020067998', 2164 + '-' + 1502, '*', '<b><span>DOLIPRANE 1000 mg Cpr Plq/100</span></b><br><br>Début : 24/12/2021<br><br><span><small>CIP13 : 3400956369553</small></span><br><span><small>CIP : 3400058</small></span>', 'systeme-nerveux', '2021-12-24', 41929));
assert.deepInclude(prescriptionItems[2], new Link('link-41929-1020038177-1020067998', 2164 + '-' + 1502, 'DOLIPRANE 1000 mg Cpr Plq/100', 'DOLIPRANE 1000 mg Cpr Plq/100', 'fading link systeme-nerveux first-link last-link', '2021-11-15', '2021-12-15'));
assert.deepInclude(prescriptionItems[3], new Link('link-41929-1020067998-1906618366', 2164 + '-' + 1502, 'DOLIPRANE 1000 mg Cpr Plq/100', 'DOLIPRANE 1000 mg Cpr Plq/100', 'fading link systeme-nerveux first-link last-link', '2021-12-24', '2022-01-23'));
});
test('builds vis-timeline data for 2 drugs having the same substance', async () => {
const dispensations = [
new FullMedicationDispense(new Drug(41929, 3400956369553, 3400058, 'DOLIPRANE 1000 mg Cpr Plq/100', undefined, Number(undefined), DrugType.PACK, '', marketStatus, undefined, undefined), new Classifications(new Classification(2164, 'SYSTEME NERVEUX', 'N', ''), new Classification(1502, 'PARACETAMOL', 'N0', '')), [{ startDate: '2021-11-15' }, { startDate: '2021-12-24' }], new Classifications(new Classification(269, 'Cancérologie - Hématologie', 'Cancérologie - Hématologie', ''), new Classification(1251, 'Progestatifs', 'Progestatifs', ''))),
new FullMedicationDispense(new Drug(182774, 3400936485464, 3400058, 'EFFERALGAN 1000 mg Cpr pell Plq/8', undefined, Number(undefined), DrugType.PACK, '', marketStatus, undefined, undefined), new Classifications(new Classification(2164, 'SYSTEME NERVEUX', 'N', ''), new Classification(1502, 'PARACETAMOL', 'N0', '')), [{ startDate: '2021-10-06' }], new Classifications(new Classification(269, 'Cancérologie - Hématologie', 'Cancérologie - Hématologie', ''), new Classification(1251, 'Progestatifs', 'Progestatifs', ''))),
];
const [atcClasses, activePrinciples, prescriptionItems] = buildTimelineData(dispensations, 'ATC', 'molecule');
assert.lengthOf(atcClasses, 1);
assert.deepInclude(atcClasses[0], new Group(2164, 'SYSTEME NERVEUX', 1, 'systeme-nerveux', [
2164 + '-' + 1502,
]));
assert.lengthOf(activePrinciples, 1);
assert.deepInclude(activePrinciples[0], new SubGroup(2164 + '-' + 1502, 2164, 'PARACETAMOL', 2, 'systeme-nerveux'));
assert.lengthOf(prescriptionItems, 6);
assert.deepInclude(prescriptionItems[0], new Point('41929-1020038177', 2164 + '-' + 1502, '*', '<b><span>DOLIPRANE 1000 mg Cpr Plq/100</span></b><br><br>Début : 15/11/2021<br><br><span><small>CIP13 : 3400956369553</small></span><br><span><small>CIP : 3400058</small></span>', 'systeme-nerveux', '2021-11-15', 41929));
assert.deepInclude(prescriptionItems[1], new Point('41929-1020067998', 2164 + '-' + 1502, '*', '<b><span>DOLIPRANE 1000 mg Cpr Plq/100</span></b><br><br>Début : 24/12/2021<br><br><span><small>CIP13 : 3400956369553</small></span><br><span><small>CIP : 3400058</small></span>', 'systeme-nerveux', '2021-12-24', 41929));
assert.deepInclude(prescriptionItems[2], new Point('182774-1020008356', 2164 + '-' + 1502, '*', '<b><span>EFFERALGAN 1000 mg Cpr pell Plq/8</span></b><br><br>Début : 06/10/2021<br><br><span><small>CIP13 : 3400936485464</small></span><br><span><small>CIP : 3400058</small></span>', 'systeme-nerveux', '2021-10-06', 182774));
assert.deepInclude(prescriptionItems[3], new Link('link-182774-1020008356-1020038146', 2164 + '-' + 1502, 'EFFERALGAN 1000 mg Cpr pell Plq/8', 'EFFERALGAN 1000 mg Cpr pell Plq/8', 'fading link systeme-nerveux first-link last-link', '2021-10-06', '2021-11-05'));
assert.deepInclude(prescriptionItems[4], new Link('link-41929-1020038177-1020067998', 2164 + '-' + 1502, 'DOLIPRANE 1000 mg Cpr Plq/100', 'DOLIPRANE 1000 mg Cpr Plq/100', 'fading link systeme-nerveux first-link last-link', '2021-11-15', '2021-12-15'));
assert.deepInclude(prescriptionItems[5], new Link('link-41929-1020067998-1906618366', 2164 + '-' + 1502, 'DOLIPRANE 1000 mg Cpr Plq/100', 'DOLIPRANE 1000 mg Cpr Plq/100', 'fading link systeme-nerveux first-link last-link', '2021-12-24', '2022-01-23'));
});
test('builds vis-timeline data for 2 drugs depending on the same ATC class', async () => {
const dispensations = [
new FullMedicationDispense(new Drug(41929, 3400956369553, 3400058, 'DOLIPRANE 1000 mg Cpr Plq/100', undefined, Number(undefined), DrugType.PACK, '', marketStatus, undefined), new Classifications(new Classification(2164, 'SYSTEME NERVEUX', 'N', ''), new Classification(1502, 'PARACETAMOL', 'N0', '')), [{ startDate: '2021-11-15' }, { startDate: '2021-12-24' }], new Classifications(new Classification(269, 'Cancérologie - Hématologie', 'Cancérologie - Hématologie', ''), new Classification(1251, 'Progestatifs', 'Progestatifs', ''))),
new FullMedicationDispense(new Drug(261973, 3400939104294, 3400058, 'ABSTRAL 100µg Cpr subl Plq/10', undefined, Number(undefined), DrugType.PACK, '', marketStatus, undefined, undefined), new Classifications(new Classification(2164, 'SYSTEME NERVEUX', 'N', ''), new Classification(1478, 'FENTANYL', 'N1', '')), [{ startDate: '2021-10-06' }], new Classifications(new Classification(269, 'Cancérologie - Hématologie', 'Cancérologie - Hématologie', ''), new Classification(1251, 'Progestatifs', 'Progestatifs', ''))),
];
const [atcClasses, activePrinciples, prescriptionItems] = buildTimelineData(dispensations, 'ATC', 'molecule');
assert.lengthOf(atcClasses, 1);
assert.deepInclude(atcClasses[0], new Group(2164, 'SYSTEME NERVEUX', 1, 'systeme-nerveux', [
2164 + '-' + 1502,
2164 + '-' + 1478,
]));
assert.lengthOf(activePrinciples, 2);
assert.deepInclude(activePrinciples[0], new SubGroup(2164 + '-' + 1502, 2164, 'PARACETAMOL', 2, 'systeme-nerveux'));
assert.deepInclude(activePrinciples[1], new SubGroup(2164 + '-' + 1478, 2164, 'FENTANYL', 2, 'systeme-nerveux'));
assert.lengthOf(prescriptionItems, 6);
});
test('builds vis-timeline data for 2 drugs depending on distinct ATC classes', async () => {
const dispensations = [
new FullMedicationDispense(new Drug(185729, 3400936563919, 3400058, 'ACETYLCYS ARRW 200mg Cpr eff Pilul/20', undefined, Number(undefined), DrugType.PACK, '', marketStatus, undefined, undefined), new Classifications(new Classification(2166, 'SYSTEME RESPIRATOIRE', 'R', ''), new Classification(1872, 'ACETYLCYSTEINE', 'R0', '')), [{ startDate: '2021-10-06' }], new Classifications(new Classification(269, 'Cancérologie - Hématologie', 'Cancérologie - Hématologie', ''), new Classification(1251, 'Progestatifs', 'Progestatifs', ''))),
new FullMedicationDispense(new Drug(41929, 3400956369553, 3400058, 'DOLIPRANE 1000 mg Cpr Plq/100', undefined, Number(undefined), DrugType.PACK, '', marketStatus, undefined, undefined), new Classifications(new Classification(2164, 'SYSTEME NERVEUX', 'N', ''), new Classification(1502, 'PARACETAMOL', 'N0', '')), [{ startDate: '2021-11-15' }], new Classifications(new Classification(269, 'Cancérologie - Hématologie', 'Cancérologie - Hématologie', ''), new Classification(1251, 'Progestatifs', 'Progestatifs', ''))),
];
const [atcClasses, activePrinciples, prescriptionItems] = buildTimelineData(dispensations, 'ATC', 'molecule');
assert.lengthOf(atcClasses, 2);
assert.deepInclude(atcClasses[0], new Group(2164, 'SYSTEME NERVEUX', 1, 'systeme-nerveux', [
2164 + '-' + 1502,
]));
assert.deepInclude(atcClasses[1], new Group(2166, 'SYSTEME RESPIRATOIRE', 1, 'systeme-respiratoire', [
2166 + '-' + 1872,
]));
assert.lengthOf(activePrinciples, 2);
assert.deepInclude(activePrinciples[0], new SubGroup(2164 + '-' + 1502, 2164, 'PARACETAMOL', 2, 'systeme-nerveux'));
assert.deepInclude(activePrinciples[1], new SubGroup(2166 + '-' + 1872, 2166, 'ACETYLCYSTEINE', 2, 'systeme-respiratoire'));
assert.lengthOf(prescriptionItems, 4);
});
//# sourceMappingURL=build_test.js.map