Nombrar la detección anterior y encadenar los tiempos de CaMa hasta el tratamiento
This commit is contained in:
+13
-29
@@ -1,4 +1,5 @@
|
||||
import { CIE10 } from './cie10';
|
||||
import { chainStarts } from './durations';
|
||||
import { NEUTRAL_DARK } from './cacu-palette';
|
||||
import { name, Reading } from './measures';
|
||||
|
||||
@@ -186,7 +187,7 @@ export interface Bars {
|
||||
export const NOT_AVAILABLE = 'No disponible';
|
||||
export const NO_PATIENTS = 'Sin pacientes en el periodo';
|
||||
const NO_ROUND =
|
||||
'Ninguna paciente del periodo tiene clasificación de detección inicial o subsecuente: los grupos en cero reflejan información no registrada, no ausencia de pacientes.';
|
||||
'Ninguna paciente del periodo tiene clasificación de detección inicial o anterior: los grupos en cero reflejan información no registrada, no ausencia de pacientes.';
|
||||
|
||||
const whole = (n: unknown): n is number => typeof n === 'number' && Number.isInteger(n) && n >= 0;
|
||||
|
||||
@@ -482,14 +483,9 @@ export function bars(mode: Mode, of: (measure: string) => Reading | undefined):
|
||||
|
||||
/** The subsequent round split by the form's last screening, drawn in place of 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'],
|
||||
];
|
||||
/** Subsequent records whose form gives none of those answers: drawn only when there are some. */
|
||||
const NO_LAST_SCREENING: [string, string] = [
|
||||
'subsequent_without_last_screening',
|
||||
'Subsecuente sin dato de última detección',
|
||||
['within_1_year', 'Detección anterior hace un año o menos'],
|
||||
['2_years', 'Detección anterior hace dos años'],
|
||||
['3_or_more_years', 'Detección anterior 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
|
||||
@@ -507,14 +503,11 @@ export function grouped(
|
||||
const history =
|
||||
mode.stratum === 'round' ? (r?.strata['subsequent_history-category'] ?? {}) : {};
|
||||
const answers = LAST_SCREENING.map(([code]) => code);
|
||||
const unanswered = Object.keys(history).filter((k) => !answers.includes(k.split('|')[0]));
|
||||
/** the cells that make up a group, with their category */
|
||||
const cellsOf = (g: string): [string, Record<string, number>][] =>
|
||||
g === NO_LAST_SCREENING[0]
|
||||
? unanswered.map((k) => [k.split('|')[1], history[k]])
|
||||
: Object.entries(answers.includes(g) ? history : cells)
|
||||
.filter(([k]) => k.split('|')[0] === g)
|
||||
.map(([k, c]) => [k.split('|')[1], c]);
|
||||
Object.entries(answers.includes(g) ? history : cells)
|
||||
.filter(([k]) => k.split('|')[0] === g)
|
||||
.map(([k, c]) => [k.split('|')[1], c]);
|
||||
const n = (g: string, c: string) =>
|
||||
cellsOf(g).reduce((t, [category, cell]) => (category === c ? t + size(cell) : t), 0);
|
||||
const reconciled = reconciles(
|
||||
@@ -532,19 +525,14 @@ export function grouped(
|
||||
const at = codes.indexOf('subsequent');
|
||||
const drawn =
|
||||
mode.stratum === 'round' && at >= 0 && r?.strata['subsequent_history-category']
|
||||
? [
|
||||
...codes.slice(0, at),
|
||||
...answers,
|
||||
...(unanswered.length ? [NO_LAST_SCREENING[0]] : []),
|
||||
...codes.slice(at + 1),
|
||||
]
|
||||
? [...codes.slice(0, at), ...answers, ...codes.slice(at + 1)]
|
||||
: codes;
|
||||
const groups: Group[] = drawn.map((code) => {
|
||||
const den = total(code);
|
||||
return {
|
||||
code,
|
||||
label:
|
||||
[...LAST_SCREENING, NO_LAST_SCREENING].find(([answer]) => answer === code)?.[1] ??
|
||||
LAST_SCREENING.find(([answer]) => answer === code)?.[1] ??
|
||||
(mode.stratum === 'age_group' &&
|
||||
code === '<25' &&
|
||||
['CACU_EU7', 'CACU_VPH_GENOTIPO'].includes(mode.measure)
|
||||
@@ -667,13 +655,9 @@ function medians(
|
||||
staggered?: boolean,
|
||||
): Bars | undefined {
|
||||
if (!rows.some((r) => r.score?.score !== undefined)) return undefined;
|
||||
// a step without a median moves nothing after it
|
||||
let elapsed = 0;
|
||||
const starts = rows.map((r) => {
|
||||
const start = elapsed;
|
||||
if (staggered) elapsed += r.score?.score ?? 0;
|
||||
return start;
|
||||
});
|
||||
const starts = staggered
|
||||
? chainStarts(rows.map((r) => ({ median: r.score?.score })))
|
||||
: rows.map(() => 0);
|
||||
const ends = rows.map(
|
||||
(r, i) => starts[i] + Math.max(r.score?.score ?? 0, r.score?.high ?? 0),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user