CaCu record: grouped NCI comparison, Spanish outcome names, survival texts and risk-only scales
The NCI comparison shows the reference once per horizon and one block per model, saying the reasons that every incompatible comparison shares only once. Outcome names are translated for display only (the API identifiers stay), and the reference outcome is read from the answer. The CaCu survival card is titled as survival and states that its curves estimate the clinical scenario's group, not an individual. Survival and recurrence estimates no longer feed the risk scales, curves, probability table or PDF.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { DecimalPipe } from '@angular/common';
|
||||
import { Component, input } from '@angular/core';
|
||||
import { Component, computed, input } from '@angular/core';
|
||||
import type { Parameters, ParametersParameter } from 'fhir/r4';
|
||||
|
||||
/** The states a resolution ends in, as the screens say them. */
|
||||
@@ -205,6 +205,86 @@ export function referenceView(answer: Parameters): ReferenceView {
|
||||
return view;
|
||||
}
|
||||
|
||||
/** Outcome names as the screens say them; presentation only: the API's identifiers stay as they are
|
||||
* (an outcome this map does not know is shown as the API gave it). */
|
||||
export const OUTCOME_TEXT: Record<string, string> = {
|
||||
'CIN3+': 'CIN3 o más grave (CIN3+)',
|
||||
'CIN2+': 'CIN2 o más grave (CIN2+)',
|
||||
cancer: 'Cáncer',
|
||||
'CIN2+ within one year': 'CIN2+ en un año',
|
||||
'not stated as a histology outcome': 'No expresado como desenlace histológico',
|
||||
};
|
||||
export const outcomeText = (outcome?: string) => (outcome ? (OUTCOME_TEXT[outcome] ?? outcome) : '');
|
||||
|
||||
export interface ModelRow extends Omit<ComparisonView, 'reasons'> {
|
||||
years: number;
|
||||
label: string;
|
||||
/** the reasons of this horizon that its model's other horizons do not share */
|
||||
reasons: string[];
|
||||
}
|
||||
export interface ModelBlock {
|
||||
model?: string;
|
||||
title?: string;
|
||||
outcome?: string;
|
||||
/** reasons shared by every non-comparable horizon of this model, said once */
|
||||
reasons: string[];
|
||||
rows: ModelRow[];
|
||||
}
|
||||
export interface Grouped {
|
||||
/** the reference by horizon: one table, whatever the models */
|
||||
reference: { years: number; label: string; published: boolean; reference?: number }[];
|
||||
/** reasons shared by every non-comparable comparison of every model, said once */
|
||||
common: string[];
|
||||
models: ModelBlock[];
|
||||
/** no institutional model evaluated her: said once, with its reasons */
|
||||
withoutModel: string[];
|
||||
}
|
||||
|
||||
const shared = (lists: string[][]) =>
|
||||
lists.length > 1 ? lists[0].filter((r) => lists.every((l) => l.includes(r))) : [];
|
||||
|
||||
/** Groups only what is equivalent: the reference once per horizon; a reason that every non-comparable
|
||||
* comparison of a model (or of all models) gives, once; everything else stays where it is. Nothing is
|
||||
* dropped, and a difference is never made: it is only the API's, on a comparable row. */
|
||||
export function groupReference(v: ReferenceView): Grouped {
|
||||
const reference = v.horizons.map((h) => ({
|
||||
years: h.years,
|
||||
label: h.label,
|
||||
published: h.published,
|
||||
reference: h.reference,
|
||||
}));
|
||||
const byModel = new Map<string, ModelBlock>();
|
||||
const withoutModel: string[] = [];
|
||||
for (const h of v.horizons)
|
||||
for (const c of h.comparisons) {
|
||||
if (!c.model) {
|
||||
for (const r of c.reasons) if (!withoutModel.includes(r)) withoutModel.push(r);
|
||||
continue;
|
||||
}
|
||||
const block = byModel.get(c.model) ?? {
|
||||
model: c.model,
|
||||
title: c.title,
|
||||
outcome: c.outcome,
|
||||
reasons: [],
|
||||
rows: [],
|
||||
};
|
||||
byModel.set(c.model, block);
|
||||
block.rows.push({ ...c, years: h.years, label: h.label });
|
||||
}
|
||||
const models = [...byModel.values()];
|
||||
const notComparable = (b: ModelBlock) => b.rows.filter((r) => r.status !== 'comparable');
|
||||
const common = shared(models.flatMap(notComparable).map((r) => r.reasons));
|
||||
const everyModel = models.length > 1 ? common : [];
|
||||
for (const b of models) {
|
||||
const own = shared(notComparable(b).map((r) => r.reasons.filter((x) => !everyModel.includes(x))));
|
||||
b.reasons = own;
|
||||
for (const r of b.rows)
|
||||
if (r.status !== 'comparable')
|
||||
r.reasons = r.reasons.filter((x) => !everyModel.includes(x) && !own.includes(x));
|
||||
}
|
||||
return { reference, common: everyModel, models, withoutModel };
|
||||
}
|
||||
|
||||
const OFFICIAL: Record<string, string> = {
|
||||
match: 'coincide con la tabla del NCI',
|
||||
'match_within_0.01': 'coincide con la tabla del NCI salvo 0.01 puntos de redondeo',
|
||||
@@ -238,10 +318,12 @@ const OFFICIAL: Record<string, string> = {
|
||||
<dd>{{ s.label }}</dd>
|
||||
</div>
|
||||
}
|
||||
<div>
|
||||
<dt>Desenlace</dt>
|
||||
<dd>CIN3 o más grave (CIN3+)</dd>
|
||||
</div>
|
||||
@if (v.source?.outcome; as out) {
|
||||
<div>
|
||||
<dt>Desenlace de la referencia</dt>
|
||||
<dd [attr.data-outcome]="out">{{ outcomeText(out) }}</dd>
|
||||
</div>
|
||||
}
|
||||
@if (v.evaluationDate ?? v.index?.sampleDate; as day) {
|
||||
<div>
|
||||
<dt>Fecha de evaluación</dt>
|
||||
@@ -269,68 +351,112 @@ const OFFICIAL: Record<string, string> = {
|
||||
</ul>
|
||||
}
|
||||
@if (v.horizons.length) {
|
||||
<table class="plain" aria-label="Comparación por horizonte">
|
||||
@let g = grouped();
|
||||
<table class="plain" aria-label="Referencia NCI por horizonte">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Horizonte</th>
|
||||
<th>Modelo institucional</th>
|
||||
<th>Referencia NCI</th>
|
||||
<th>Diferencia (puntos porcentuales)</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@for (h of v.horizons; track h.years) {
|
||||
@for (c of h.comparisons.length ? h.comparisons : [none]; track $index) {
|
||||
<tr [attr.data-years]="h.years">
|
||||
<td class="nowrap" data-label="Horizonte">{{ h.label }}</td>
|
||||
<td class="model" data-label="Modelo institucional">
|
||||
@if (c.model) {
|
||||
<strong>{{ c.title }}</strong>
|
||||
<span class="muted">{{ c.outcome }}</span>
|
||||
}
|
||||
@if (c.institutional !== undefined) {
|
||||
{{ c.institutional * 100 | number: '1.2-2' }} %
|
||||
@if (c.low !== undefined && c.high !== undefined) {
|
||||
<span class="muted"
|
||||
>(IC 95 %: {{ c.low * 100 | number: '1.2-2' }}–{{
|
||||
c.high * 100 | number: '1.2-2'
|
||||
}}
|
||||
%)</span
|
||||
>
|
||||
}
|
||||
} @else {
|
||||
<span>No disponible</span>
|
||||
}
|
||||
</td>
|
||||
<td class="nowrap" data-label="Referencia NCI">
|
||||
@if (h.reference !== undefined) {
|
||||
<strong>{{ h.reference * 100 | number: '1.2-2' }} %</strong>
|
||||
} @else {
|
||||
<span>No publicado</span>
|
||||
}
|
||||
</td>
|
||||
<td data-label="Diferencia (puntos porcentuales)">
|
||||
@if (c.status === 'comparable' && c.differencePp !== undefined) {
|
||||
<strong
|
||||
>{{ c.differencePp > 0 ? '+' : ''
|
||||
}}{{ c.differencePp | number: '1.2-2' }}</strong
|
||||
>
|
||||
} @else {
|
||||
<span>No comparable</span>
|
||||
@if (c.reasons.length) {
|
||||
<ul class="why">
|
||||
@for (r of c.reasons; track r) {
|
||||
<li>{{ reasonText(r) }}</li>
|
||||
}
|
||||
</ul>
|
||||
}
|
||||
}
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
@for (h of g.reference; track h.years) {
|
||||
<tr [attr.data-years]="h.years">
|
||||
<td class="nowrap" data-label="Horizonte">{{ h.label }}</td>
|
||||
<td class="nowrap" data-label="Referencia NCI">
|
||||
@if (h.reference !== undefined) {
|
||||
<strong>{{ h.reference * 100 | number: '1.2-2' }} %</strong>
|
||||
} @else {
|
||||
<span>No publicado</span>
|
||||
}
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
<h4>Modelos institucionales</h4>
|
||||
@if (g.withoutModel.length || !g.models.length) {
|
||||
<p class="nomodel">
|
||||
<strong>No disponible</strong>
|
||||
</p>
|
||||
<ul class="why" aria-label="Motivo">
|
||||
@for (r of g.withoutModel; track r) {
|
||||
<li>{{ reasonText(r) }}</li>
|
||||
}
|
||||
</ul>
|
||||
}
|
||||
@if (g.common.length) {
|
||||
<p class="muted">Motivos que comparten todas las comparaciones no válidas:</p>
|
||||
<ul class="why" aria-label="Motivos comunes">
|
||||
@for (r of g.common; track r) {
|
||||
<li>{{ reasonText(r) }}</li>
|
||||
}
|
||||
</ul>
|
||||
}
|
||||
@for (m of g.models; track m.model) {
|
||||
<section class="model" [attr.data-model]="m.model" [attr.aria-label]="m.title">
|
||||
<h5>
|
||||
{{ m.title }}
|
||||
<span class="muted" [attr.data-outcome]="m.outcome">{{ outcomeText(m.outcome) }}</span>
|
||||
</h5>
|
||||
@if (m.reasons.length) {
|
||||
<p class="muted">No comparable en estos horizontes:</p>
|
||||
<ul class="why" aria-label="Motivos del modelo">
|
||||
@for (r of m.reasons; track r) {
|
||||
<li>{{ reasonText(r) }}</li>
|
||||
}
|
||||
</ul>
|
||||
}
|
||||
<table class="plain" [attr.aria-label]="'Comparación de ' + m.title">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Horizonte</th>
|
||||
<th>Modelo institucional</th>
|
||||
<th>Diferencia (puntos porcentuales)</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@for (c of m.rows; track c.years) {
|
||||
<tr [attr.data-years]="c.years">
|
||||
<td class="nowrap" data-label="Horizonte">{{ c.label }}</td>
|
||||
<td data-label="Modelo institucional">
|
||||
@if (c.institutional !== undefined) {
|
||||
{{ c.institutional * 100 | number: '1.2-2' }} %
|
||||
@if (c.low !== undefined && c.high !== undefined) {
|
||||
<span class="muted"
|
||||
>(IC 95 %: {{ c.low * 100 | number: '1.2-2' }}–{{
|
||||
c.high * 100 | number: '1.2-2'
|
||||
}}
|
||||
%)</span
|
||||
>
|
||||
}
|
||||
} @else {
|
||||
<span>No disponible</span>
|
||||
}
|
||||
</td>
|
||||
<td data-label="Diferencia (puntos porcentuales)">
|
||||
@if (c.status === 'comparable' && c.differencePp !== undefined) {
|
||||
<strong
|
||||
>{{ c.differencePp > 0 ? '+' : ''
|
||||
}}{{ c.differencePp | number: '1.2-2' }}</strong
|
||||
>
|
||||
} @else {
|
||||
<span>No comparable</span>
|
||||
@if (c.reasons.length) {
|
||||
<ul class="why">
|
||||
@for (r of c.reasons; track r) {
|
||||
<li>{{ reasonText(r) }}</li>
|
||||
}
|
||||
</ul>
|
||||
}
|
||||
}
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</section>
|
||||
}
|
||||
<p class="muted note">
|
||||
La diferencia es el riesgo institucional menos el riesgo NCI y solo se calcula si ambos
|
||||
estiman lo mismo (desenlace, horizonte, fecha índice y población verificados).
|
||||
@@ -406,6 +532,7 @@ const OFFICIAL: Record<string, string> = {
|
||||
table {
|
||||
border-collapse: collapse;
|
||||
width: 100%;
|
||||
table-layout: fixed;
|
||||
}
|
||||
th,
|
||||
td {
|
||||
@@ -413,9 +540,18 @@ const OFFICIAL: Record<string, string> = {
|
||||
text-align: left;
|
||||
vertical-align: top;
|
||||
}
|
||||
.model strong,
|
||||
.model .muted {
|
||||
display: block;
|
||||
.model {
|
||||
border-top: 1px solid #dce3e7;
|
||||
margin-top: 8px;
|
||||
padding-top: 4px;
|
||||
}
|
||||
h4,
|
||||
h5 {
|
||||
margin: 12px 0 4px;
|
||||
}
|
||||
h5 .muted {
|
||||
font-weight: 400;
|
||||
margin-left: 8px;
|
||||
}
|
||||
.why {
|
||||
margin: 4px 0;
|
||||
@@ -463,10 +599,10 @@ const OFFICIAL: Record<string, string> = {
|
||||
})
|
||||
export class ReferenceRisk {
|
||||
readonly view = input.required<ReferenceView>();
|
||||
protected readonly none: ComparisonView = {
|
||||
status: 'not_comparable',
|
||||
reasons: ['no_institutional_model'],
|
||||
};
|
||||
protected readonly grouped = computed(() => groupReference(this.view()));
|
||||
protected outcomeText(outcome?: string) {
|
||||
return outcomeText(outcome);
|
||||
}
|
||||
protected statusText(status: string) {
|
||||
return STATUS_TEXT[status] ?? status;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user