Dibujar la ronda subsecuente por última detección y conectar diagnóstico a tratamiento de CaMa
This commit is contained in:
+22
-24
@@ -471,24 +471,12 @@ 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 subsequent round split by the form's last screening, drawn after that round's group. */
|
||||
const LAST_SCREENING: [string, string][] = [
|
||||
['within_1_year', 'Subsecuente: última detección hace un año o menos'],
|
||||
['2_years', 'Subsecuente: última detección hace dos años'],
|
||||
['3_or_more_years', 'Subsecuente: última detección hace tres años o más'],
|
||||
];
|
||||
|
||||
/** 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
|
||||
@@ -502,7 +490,11 @@ export function grouped(
|
||||
const cells = r?.strata[`${mode.stratum}-category`] ?? {};
|
||||
const found = [...new Set(Object.keys(cells).map((k) => k.split('|')[0]))];
|
||||
if (!patients(r) || !found.length) return undefined;
|
||||
const n = (g: string, c: string) => size(cells[`${g}|${c}`]);
|
||||
const history =
|
||||
mode.stratum === 'round' ? (r?.strata['subsequent_history-category'] ?? {}) : {};
|
||||
const answers = LAST_SCREENING.map(([code]) => code);
|
||||
const n = (g: string, c: string) =>
|
||||
size((answers.includes(g) ? history : cells)[`${g}|${c}`]);
|
||||
const reconciled = reconciles(
|
||||
Object.values(cells).map((c) => c['initial-population']),
|
||||
patients(r),
|
||||
@@ -513,20 +505,26 @@ export function grouped(
|
||||
];
|
||||
const total = (g: string) =>
|
||||
mode.ofAll
|
||||
? Object.entries(cells)
|
||||
? Object.entries(answers.includes(g) ? history : cells)
|
||||
.filter(([k]) => k.split('|')[0] === g)
|
||||
.reduce((t, [, c]) => t + size(c), 0)
|
||||
: mode.catalog.reduce((t, c) => t + n(g, c.code), 0);
|
||||
const groups: Group[] = codes.map((code) => {
|
||||
const at = codes.indexOf('subsequent');
|
||||
const drawn =
|
||||
mode.stratum === 'round' && at >= 0 && r?.strata['subsequent_history-category']
|
||||
? [...codes.slice(0, at + 1), ...answers, ...codes.slice(at + 1)]
|
||||
: codes;
|
||||
const groups: Group[] = drawn.map((code) => {
|
||||
const den = total(code);
|
||||
return {
|
||||
code,
|
||||
label:
|
||||
mode.stratum === 'age_group' &&
|
||||
LAST_SCREENING.find(([answer]) => answer === code)?.[1] ??
|
||||
(mode.stratum === 'age_group' &&
|
||||
code === '<25' &&
|
||||
['CACU_EU7', 'CACU_VPH_GENOTIPO'].includes(mode.measure)
|
||||
? '15-24'
|
||||
: name(code),
|
||||
: name(code)),
|
||||
total: den,
|
||||
hint: den ? undefined : `Sin ${mode.unit} en el grupo`,
|
||||
rows: mode.catalog.flatMap((c, index) => {
|
||||
@@ -562,7 +560,7 @@ export function grouped(
|
||||
let note = hiddenNote(mode, of);
|
||||
if (mode.complete) {
|
||||
const unclassified = total('no_data');
|
||||
const classified = groups.filter((g) => g.code !== 'no_data');
|
||||
const classified = groups.filter((g) => g.code !== 'no_data' && !answers.includes(g.code));
|
||||
const none = classified.every((g) => !g.total);
|
||||
const sentence = !reconciled
|
||||
? 'Los conteos del informe no concilian con el total: los grupos ausentes no se muestran como cero.'
|
||||
|
||||
Reference in New Issue
Block a user