Dibujar la ronda subsecuente por última detección y conectar diagnóstico a tratamiento de CaMa
This commit is contained in:
@@ -508,3 +508,27 @@ describe('independent bars by group', () => {
|
|||||||
expect(bars(mode as any, () => r)!.rows.map((x) => x.color)).toEqual(['#a', '#b']);
|
expect(bars(mode as any, () => r)!.rows.map((x) => x.color)).toEqual(['#a', '#b']);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
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 });
|
||||||
|
const r: Reading = {
|
||||||
|
populations: { 'initial-population': 3 },
|
||||||
|
strata: {
|
||||||
|
'round-category': { 'subsequent|NILM': cell(3) },
|
||||||
|
'subsequent_history-category': { 'within_1_year|NILM': cell(2) },
|
||||||
|
},
|
||||||
|
};
|
||||||
|
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],
|
||||||
|
['2_years', 0],
|
||||||
|
['3_or_more_years', 0],
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|||||||
+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. */
|
/** The subsequent round split by the form's last screening, drawn after that round's group. */
|
||||||
export function subsequentHistory(reading?: Reading) {
|
const LAST_SCREENING: [string, string][] = [
|
||||||
const values = reading?.strata['subsequent_history'];
|
['within_1_year', 'Subsecuente: última detección hace un año o menos'],
|
||||||
const den = reading?.strata['round']?.['subsequent']?.['initial-population'] ?? 0;
|
['2_years', 'Subsecuente: última detección hace dos años'],
|
||||||
if (!values) return undefined;
|
['3_or_more_years', 'Subsecuente: última detección hace tres años o más'],
|
||||||
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
|
/** 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
|
* 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 cells = r?.strata[`${mode.stratum}-category`] ?? {};
|
||||||
const found = [...new Set(Object.keys(cells).map((k) => k.split('|')[0]))];
|
const found = [...new Set(Object.keys(cells).map((k) => k.split('|')[0]))];
|
||||||
if (!patients(r) || !found.length) return undefined;
|
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(
|
const reconciled = reconciles(
|
||||||
Object.values(cells).map((c) => c['initial-population']),
|
Object.values(cells).map((c) => c['initial-population']),
|
||||||
patients(r),
|
patients(r),
|
||||||
@@ -513,20 +505,26 @@ export function grouped(
|
|||||||
];
|
];
|
||||||
const total = (g: string) =>
|
const total = (g: string) =>
|
||||||
mode.ofAll
|
mode.ofAll
|
||||||
? Object.entries(cells)
|
? Object.entries(answers.includes(g) ? history : cells)
|
||||||
.filter(([k]) => k.split('|')[0] === g)
|
.filter(([k]) => k.split('|')[0] === g)
|
||||||
.reduce((t, [, c]) => t + size(c), 0)
|
.reduce((t, [, c]) => t + size(c), 0)
|
||||||
: mode.catalog.reduce((t, c) => t + n(g, c.code), 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);
|
const den = total(code);
|
||||||
return {
|
return {
|
||||||
code,
|
code,
|
||||||
label:
|
label:
|
||||||
mode.stratum === 'age_group' &&
|
LAST_SCREENING.find(([answer]) => answer === code)?.[1] ??
|
||||||
|
(mode.stratum === 'age_group' &&
|
||||||
code === '<25' &&
|
code === '<25' &&
|
||||||
['CACU_EU7', 'CACU_VPH_GENOTIPO'].includes(mode.measure)
|
['CACU_EU7', 'CACU_VPH_GENOTIPO'].includes(mode.measure)
|
||||||
? '15-24'
|
? '15-24'
|
||||||
: name(code),
|
: name(code)),
|
||||||
total: den,
|
total: den,
|
||||||
hint: den ? undefined : `Sin ${mode.unit} en el grupo`,
|
hint: den ? undefined : `Sin ${mode.unit} en el grupo`,
|
||||||
rows: mode.catalog.flatMap((c, index) => {
|
rows: mode.catalog.flatMap((c, index) => {
|
||||||
@@ -562,7 +560,7 @@ export function grouped(
|
|||||||
let note = hiddenNote(mode, of);
|
let note = hiddenNote(mode, of);
|
||||||
if (mode.complete) {
|
if (mode.complete) {
|
||||||
const unclassified = total('no_data');
|
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 none = classified.every((g) => !g.total);
|
||||||
const sentence = !reconciled
|
const sentence = !reconciled
|
||||||
? 'Los conteos del informe no concilian con el total: los grupos ausentes no se muestran como cero.'
|
? 'Los conteos del informe no concilian con el total: los grupos ausentes no se muestran como cero.'
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
import { HISTORY, PAGES } from './pages';
|
||||||
|
|
||||||
|
describe('tiempo de diagnóstico tras biopsia a tratamiento en CaMa', () => {
|
||||||
|
it('conecta la tarjeta y el histórico con la medida', () => {
|
||||||
|
const measure = 'CAMA_DIAS_DIAGNOSTICO_TRATAMIENTO';
|
||||||
|
expect(PAGES['cama'].kpis.some((card) => card.measure === measure)).toBe(true);
|
||||||
|
expect(HISTORY['cama'].panels.some((panel) => panel.measure === measure)).toBe(true);
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -273,9 +273,9 @@ export const PAGES: Record<string, Page> = {
|
|||||||
...CAMA_DAYS,
|
...CAMA_DAYS,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'Tiempo de diagnóstico a tratamiento',
|
measure: 'CAMA_DIAS_DIAGNOSTICO_TRATAMIENTO',
|
||||||
value: 'Indicador no disponible',
|
title: 'Tiempo de diagnóstico tras biopsia a tratamiento',
|
||||||
note: 'Indicador no publicado en el catálogo institucional.',
|
...CAMA_DAYS,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
measure: 'CAMA_DIAS_TOMA_DIAGNOSTICO',
|
measure: 'CAMA_DIAS_TOMA_DIAGNOSTICO',
|
||||||
@@ -522,6 +522,7 @@ export const HISTORY: Record<string, History> = {
|
|||||||
cama: {
|
cama: {
|
||||||
line: '#9C42C2',
|
line: '#9C42C2',
|
||||||
panels: [
|
panels: [
|
||||||
|
{ title: 'Tiempo de diagnóstico tras biopsia a tratamiento', measure: 'CAMA_DIAS_DIAGNOSTICO_TRATAMIENTO', kind: 'median' },
|
||||||
{
|
{
|
||||||
title: 'Días de la toma de la mastografía a su resultado',
|
title: 'Días de la toma de la mastografía a su resultado',
|
||||||
measure: 'CAMA_EU38A',
|
measure: 'CAMA_EU38A',
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { Component, computed, input, signal } from '@angular/core';
|
|||||||
import { MatButtonToggleModule } from '@angular/material/button-toggle';
|
import { MatButtonToggleModule } from '@angular/material/button-toggle';
|
||||||
import { Loading } from '../loading';
|
import { Loading } from '../loading';
|
||||||
import { Figure, Plot } from '../plot';
|
import { Figure, Plot } from '../plot';
|
||||||
import { bars, grouped, hiddenNote, Mode, subsequentHistory, unavailable } from './bars';
|
import { bars, grouped, hiddenNote, Mode, unavailable } from './bars';
|
||||||
import { Reading } from './measures';
|
import { Reading } from './measures';
|
||||||
|
|
||||||
/** A card read one mode at a time: its title, its headline, the toggle and the bars. */
|
/** A card read one mode at a time: its title, its headline, the toggle and the bars. */
|
||||||
@@ -77,16 +77,6 @@ import { Reading } from './measures';
|
|||||||
@if (g.note) {
|
@if (g.note) {
|
||||||
<p class="state">{{ g.note }}</p>
|
<p class="state">{{ g.note }}</p>
|
||||||
}
|
}
|
||||||
@if (historyBreakdown(); as history) {
|
|
||||||
<section aria-label="Última detección en la ronda subsecuente">
|
|
||||||
<h4>Detección subsecuente por tiempo desde la última detección</h4>
|
|
||||||
<ul>
|
|
||||||
@for (item of history; track item.label) {
|
|
||||||
<li>{{ item.label }}: {{ item.text }}</li>
|
|
||||||
}
|
|
||||||
</ul>
|
|
||||||
</section>
|
|
||||||
}
|
|
||||||
} @else if (figure(); as f) {
|
} @else if (figure(); as f) {
|
||||||
<app-plot [figure]="f" [height]="height()" />
|
<app-plot [figure]="f" [height]="height()" />
|
||||||
@if (hidden(); as why) {
|
@if (hidden(); as why) {
|
||||||
@@ -387,11 +377,6 @@ export class Readings {
|
|||||||
() => this.modes().find((m) => m.label === (this.view() || this.chosen())) ?? this.modes()[0],
|
() => this.modes().find((m) => m.label === (this.view() || this.chosen())) ?? this.modes()[0],
|
||||||
);
|
);
|
||||||
protected readonly groups = computed(() => grouped(this.mode(), this.read()));
|
protected readonly groups = computed(() => grouped(this.mode(), this.read()));
|
||||||
protected readonly historyBreakdown = computed(() => {
|
|
||||||
const mode = this.mode();
|
|
||||||
if (mode.kind !== 'grouped' || mode.stratum !== 'round') return undefined;
|
|
||||||
return subsequentHistory(this.read()(mode.measure));
|
|
||||||
});
|
|
||||||
protected readonly table = computed(() => bars(this.mode(), this.read()));
|
protected readonly table = computed(() => bars(this.mode(), this.read()));
|
||||||
/** The bars of a scenarios figure need more room than a donut. */
|
/** The bars of a scenarios figure need more room than a donut. */
|
||||||
protected readonly height = computed(() => {
|
protected readonly height = computed(() => {
|
||||||
|
|||||||
Reference in New Issue
Block a user