Restituir el desglose de la ronda subsecuente y sangrar las citologías anormales
This commit is contained in:
@@ -123,6 +123,7 @@ export type Tint = { bar: string; mark: string };
|
||||
|
||||
/** One category of a group as an independent bar of 0 to 100 %: its records over the group's. */
|
||||
export interface GroupRow {
|
||||
sub?: boolean;
|
||||
label: string;
|
||||
color: string;
|
||||
count: number;
|
||||
@@ -149,6 +150,8 @@ export interface Groups {
|
||||
|
||||
/** One bar: its length and quartile marks in % of the scale, and its cells of text. */
|
||||
export interface Bar {
|
||||
/** one of the categories the aggregate row above adds up */
|
||||
sub?: boolean;
|
||||
label: string;
|
||||
/** why the row has no figures: no patients in the group, or not available */
|
||||
hint?: string;
|
||||
@@ -267,7 +270,8 @@ export function bars(mode: Mode, of: (measure: string) => Reading | undefined):
|
||||
rows: all.flatMap(({ code, label, color }, index) => {
|
||||
const n = size(cells[code]);
|
||||
const cols = [`${n}`, pct(n, total)];
|
||||
const row = { label, color, width: (100 * n) / most, marks: [], cells: cols };
|
||||
const part = !!mode.aggregate?.codes.includes(code);
|
||||
const row = { label, color, width: (100 * n) / most, marks: [], cells: cols, sub: part };
|
||||
if (index !== 0 || !mode.aggregate) return [row];
|
||||
const a = mode.aggregate;
|
||||
const sum = a.codes.reduce((total, key) => total + size(cells[key]), 0);
|
||||
@@ -467,6 +471,25 @@ export function bars(mode: Mode, of: (measure: string) => Reading | undefined):
|
||||
}
|
||||
}
|
||||
|
||||
/** The form's last-screening answers within the subsequent round, over that round's total. */
|
||||
export function subsequentHistory(reading?: Reading) {
|
||||
const values = reading?.strata['subsequent_history'];
|
||||
const den = reading?.strata['round']?.['subsequent']?.['initial-population'] ?? 0;
|
||||
if (!values) return undefined;
|
||||
return [
|
||||
['within_1_year', 'Un año o menos'],
|
||||
['2_years', 'Dos años'],
|
||||
['3_or_more_years', 'Tres o más años'],
|
||||
['no_data', 'Sin dato'],
|
||||
].map(([code, label]) => {
|
||||
const count = values[code]?.['initial-population'] ?? 0;
|
||||
return {
|
||||
label,
|
||||
text: `${count}/${den} · ${den ? ((100 * count) / den).toFixed(1) + ' %' : '—'}`,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
/** The groups of a grouped mode: each group (an age group, a follow-up status, a screening round) with
|
||||
* one independent bar per category over the group's own records. A group the report leaves out is
|
||||
* drawn empty only when the listed ones add up to every record of the period (`complete`). */
|
||||
@@ -515,6 +538,7 @@ export function grouped(
|
||||
count,
|
||||
of: den,
|
||||
percent,
|
||||
sub: !!mode.aggregate?.codes.includes(c.code),
|
||||
text: `${count}/${den} · ${percent === undefined ? '—' : percent.toFixed(1) + ' %'}`,
|
||||
};
|
||||
if (index !== 0 || !mode.aggregate) return [row];
|
||||
|
||||
Reference in New Issue
Block a user