Restituir el desglose de la ronda subsecuente y sangrar las citologías anormales
This commit is contained in:
@@ -93,6 +93,7 @@ describe('bars', () => {
|
|||||||
const aggregate = { label: 'Anormal', color: '#f00', codes: ['LSIL', 'HSIL'] };
|
const aggregate = { label: 'Anormal', color: '#f00', codes: ['LSIL', 'HSIL'] };
|
||||||
const t = bars({ kind: 'counts', label: 'x', measure: 'M', catalog, aggregate }, () => r)!;
|
const t = bars({ kind: 'counts', label: 'x', measure: 'M', catalog, aggregate }, () => r)!;
|
||||||
expect(t.rows[1].cells).toEqual(['3', '30.0 %']);
|
expect(t.rows[1].cells).toEqual(['3', '30.0 %']);
|
||||||
|
expect(t.rows.map((row) => !!row.sub)).toEqual([false, false, true, true, false].slice(0, t.rows.length));
|
||||||
const g = grouped(
|
const g = grouped(
|
||||||
{
|
{
|
||||||
kind: 'grouped',
|
kind: 'grouped',
|
||||||
|
|||||||
@@ -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. */
|
/** One category of a group as an independent bar of 0 to 100 %: its records over the group's. */
|
||||||
export interface GroupRow {
|
export interface GroupRow {
|
||||||
|
sub?: boolean;
|
||||||
label: string;
|
label: string;
|
||||||
color: string;
|
color: string;
|
||||||
count: number;
|
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. */
|
/** One bar: its length and quartile marks in % of the scale, and its cells of text. */
|
||||||
export interface Bar {
|
export interface Bar {
|
||||||
|
/** one of the categories the aggregate row above adds up */
|
||||||
|
sub?: boolean;
|
||||||
label: string;
|
label: string;
|
||||||
/** why the row has no figures: no patients in the group, or not available */
|
/** why the row has no figures: no patients in the group, or not available */
|
||||||
hint?: string;
|
hint?: string;
|
||||||
@@ -267,7 +270,8 @@ export function bars(mode: Mode, of: (measure: string) => Reading | undefined):
|
|||||||
rows: all.flatMap(({ code, label, color }, index) => {
|
rows: all.flatMap(({ code, label, color }, index) => {
|
||||||
const n = size(cells[code]);
|
const n = size(cells[code]);
|
||||||
const cols = [`${n}`, pct(n, total)];
|
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];
|
if (index !== 0 || !mode.aggregate) return [row];
|
||||||
const a = mode.aggregate;
|
const a = mode.aggregate;
|
||||||
const sum = a.codes.reduce((total, key) => total + size(cells[key]), 0);
|
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
|
/** 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
|
||||||
* drawn empty only when the listed ones add up to every record of the period (`complete`). */
|
* drawn empty only when the listed ones add up to every record of the period (`complete`). */
|
||||||
@@ -515,6 +538,7 @@ export function grouped(
|
|||||||
count,
|
count,
|
||||||
of: den,
|
of: den,
|
||||||
percent,
|
percent,
|
||||||
|
sub: !!mode.aggregate?.codes.includes(c.code),
|
||||||
text: `${count}/${den} · ${percent === undefined ? '—' : percent.toFixed(1) + ' %'}`,
|
text: `${count}/${den} · ${percent === undefined ? '—' : percent.toFixed(1) + ' %'}`,
|
||||||
};
|
};
|
||||||
if (index !== 0 || !mode.aggregate) return [row];
|
if (index !== 0 || !mode.aggregate) return [row];
|
||||||
|
|||||||
@@ -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, unavailable } from './bars';
|
import { bars, grouped, hiddenNote, Mode, subsequentHistory, 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. */
|
||||||
@@ -60,7 +60,7 @@ import { Reading } from './measures';
|
|||||||
}
|
}
|
||||||
</h4>
|
</h4>
|
||||||
@for (row of group.rows; track row.label) {
|
@for (row of group.rows; track row.label) {
|
||||||
<div class="row" [attr.data-category]="row.label">
|
<div class="row" [class.sub]="row.sub" [attr.data-category]="row.label">
|
||||||
<span class="name">{{ row.label }}</span>
|
<span class="name">{{ row.label }}</span>
|
||||||
<span class="track" aria-hidden="true">
|
<span class="track" aria-hidden="true">
|
||||||
<span
|
<span
|
||||||
@@ -77,6 +77,16 @@ 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) {
|
||||||
@@ -94,7 +104,7 @@ import { Reading } from './measures';
|
|||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@for (row of t.rows; track row.label) {
|
@for (row of t.rows; track row.label) {
|
||||||
<tr>
|
<tr [class.sub]="row.sub">
|
||||||
<th scope="row">
|
<th scope="row">
|
||||||
{{ row.label }}
|
{{ row.label }}
|
||||||
@if (row.hint) {
|
@if (row.hint) {
|
||||||
@@ -151,6 +161,10 @@ import { Reading } from './measures';
|
|||||||
}
|
}
|
||||||
`,
|
`,
|
||||||
styles: `
|
styles: `
|
||||||
|
tr.sub th,
|
||||||
|
.row.sub .name {
|
||||||
|
padding-left: 1.25rem;
|
||||||
|
}
|
||||||
:host {
|
:host {
|
||||||
display: block;
|
display: block;
|
||||||
min-width: 0;
|
min-width: 0;
|
||||||
@@ -373,6 +387,11 @@ 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