Indicators: CaCu and CaMa pages read by rounds, genotypes and steps; history to a chosen period; NCI and indicator references; CaMa follow-up export; API client for eligibility and risk series

This commit is contained in:
Roberto Treviño
2026-12-05 23:46:51 -06:00
parent e0084ef9ff
commit d3f6f5c214
45 changed files with 2694 additions and 1157 deletions
+52 -7
View File
@@ -1,6 +1,9 @@
import { bars } from './bars';
import { bars, Mode } from './bars';
import { Reading } from './measures';
const read = (r: Reading) => () => r;
const cells = (mode: Mode, r: Reading) => bars(mode, read(r))!.rows.map((x) => x.cells);
describe('bars', () => {
it('list every category, so the shares add up', () => {
const r: Reading = {
@@ -10,18 +13,60 @@ describe('bars', () => {
},
};
const catalog = [{ code: 'a', label: 'A', color: '#000' }];
const t = bars({ kind: 'counts', label: 'x', measure: 'M', catalog }, () => r)!;
expect(t.rows.map((x) => x.cells)).toEqual([
expect(cells({ kind: 'counts', label: 'x', measure: 'M', catalog }, r)).toEqual([
['3', '75.0 %'],
['1', '25.0 %'],
]);
});
it('a group with no patients has no rate', () => {
it('add up an aggregate after the first row and indent its parts', () => {
const r: Reading = {
populations: {},
strata: { s: { initial: { numerator: 0, denominator: 0 } } },
strata: {
category: {
n: { 'initial-population': 6 },
a: { 'initial-population': 3 },
b: { 'initial-population': 1 },
},
},
};
const mode = { kind: 'shares', label: 'x', measure: 'M', stratum: 's', order: ['initial'] };
expect(bars(mode as any, () => r)!.rows[0].cells).toEqual(['0/0', '—']);
const catalog = ['n', 'a', 'b'].map((code) => ({ code, label: code, color: '#000' }));
const aggregate = { label: 'Anormal', color: '#f00', codes: ['a', 'b'] };
const t = bars({ kind: 'counts', label: 'x', measure: 'M', catalog, aggregate }, read(r))!;
expect(t.rows.map((x) => [x.label, x.cells[0], !!x.sub])).toEqual([
['n', '6', false],
['Anormal', '4', false],
['a', '3', true],
['b', '1', true],
]);
});
it('draw a proportion with its interval as marks', () => {
const r: Reading = {
populations: { numerator: 51, denominator: 70 },
strata: {},
score: 0.729,
low: 0.615,
high: 0.819,
};
const t = bars({ kind: 'ratio', label: 'Total', measure: 'M' }, read(r))!;
expect(t.rows[0].cells).toEqual(['51/70', '72.9 %', '61.5 %–81.9 %']);
expect(t.rows[0].marks.map(Math.round)).toEqual([62, 82]);
});
it('stagger steps from where the step they follow ends', () => {
const at: Record<string, Reading> = {
A: { populations: { 'measure-observation': 3 }, strata: {}, score: 10 },
B: { populations: { 'measure-observation': 2 }, strata: {}, score: 30 },
C: { populations: { 'measure-observation': 1 }, strata: {}, score: 20 },
};
const steps = [
{ label: 'a', measure: 'A' },
{ label: 'b', measure: 'B' },
{ label: 'c', measure: 'C', after: 0 },
{ label: 'd', measure: 'D' },
];
const mode: Mode = { kind: 'days', label: 'x', steps, staggered: true, scale: true };
const t = bars(mode, (m) => at[m])!;
expect(t.rows.map((x) => x.offset)).toEqual([0, 25, 25, undefined]);
expect(t.rows[3].none).toBe('Sin mediciones en el periodo');
expect(t.note).toBe('Escala: 0 a 40 días.');
});
});