Separar la ronda subsecuente por última detección y encadenar los tiempos por paso
This commit is contained in:
@@ -510,25 +510,51 @@ describe('independent bars by group', () => {
|
||||
});
|
||||
|
||||
describe('the subsequent round by last screening', () => {
|
||||
it('draws each answer as its own group after the subsequent one', () => {
|
||||
const cell = (n: number) => ({ 'initial-population': n });
|
||||
it('chains the steps of a time window, quartiles moving with their bar', () => {
|
||||
const median = (score: number, low: number, high: number): Reading => ({
|
||||
populations: { 'measure-observation': 1 },
|
||||
strata: {},
|
||||
score,
|
||||
low,
|
||||
high,
|
||||
});
|
||||
const steps = [
|
||||
{ label: 'a', measure: 'A' },
|
||||
{ label: 'b', measure: 'B' },
|
||||
];
|
||||
const table = bars({ kind: 'days', label: 'x', steps, staggered: true }, (m) =>
|
||||
m === 'A' ? median(10, 5, 10) : median(20, 10, 30),
|
||||
)!;
|
||||
expect(table.rows.map((r) => [r.offset, r.width, r.marks])).toEqual([
|
||||
[0, 25, [12.5, 25]],
|
||||
[25, 50, [50, 100]],
|
||||
]);
|
||||
});
|
||||
it('splits the subsequent round by last screening, keeping those without an answer', () => {
|
||||
const one = { 'initial-population': 1 };
|
||||
const r: Reading = {
|
||||
populations: { 'initial-population': 3 },
|
||||
strata: {
|
||||
'round-category': { 'subsequent|NILM': cell(3) },
|
||||
'subsequent_history-category': { 'within_1_year|NILM': cell(2) },
|
||||
'round-category': { 'initial|a': one, 'subsequent|a': { 'initial-population': 2 } },
|
||||
'subsequent_history-category': { 'within_1_year|a': one, 'no_data|a': one },
|
||||
},
|
||||
};
|
||||
const catalog = [{ code: 'NILM', label: 'Normal', color: '#000' }];
|
||||
const found = grouped(
|
||||
{ kind: 'grouped', label: 'x', measure: 'M', catalog, unit: 'pacientes', stratum: 'round', order: ['subsequent'] },
|
||||
() => r,
|
||||
)!;
|
||||
expect(found.groups.map((g) => [g.code, g.total])).toEqual([
|
||||
['subsequent', 3],
|
||||
['within_1_year', 2],
|
||||
const mode: Mode = {
|
||||
kind: 'grouped',
|
||||
label: 'x',
|
||||
measure: 'M',
|
||||
stratum: 'round',
|
||||
order: ['initial', 'subsequent'],
|
||||
unit: 'pacientes',
|
||||
catalog: [{ code: 'a', label: 'A', color: '#000' }],
|
||||
};
|
||||
const { groups } = grouped(mode, () => r)!;
|
||||
expect(groups.map((g) => [g.code, g.total])).toEqual([
|
||||
['initial', 1],
|
||||
['within_1_year', 1],
|
||||
['2_years', 0],
|
||||
['3_or_more_years', 0],
|
||||
['subsequent_without_last_screening', 1],
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user