Mostrar factores usados en cada estimación
This commit is contained in:
@@ -566,6 +566,10 @@
|
|||||||
<app-loading what="las curvas de supervivencia" [figure]="true" />
|
<app-loading what="las curvas de supervivencia" [figure]="true" />
|
||||||
} @else if (domain() === 'cacu') {
|
} @else if (domain() === 'cacu') {
|
||||||
<p class="muted">No disponible: el informe no contiene la curva para esta combinación.</p>
|
<p class="muted">No disponible: el informe no contiene la curva para esta combinación.</p>
|
||||||
|
<details>
|
||||||
|
<summary>Métodos</summary>
|
||||||
|
<p class="muted">No hay un método publicado para esta combinación.</p>
|
||||||
|
</details>
|
||||||
} @else if (survival.value(); as s) {
|
} @else if (survival.value(); as s) {
|
||||||
<h3>Escenario clínico de la paciente</h3>
|
<h3>Escenario clínico de la paciente</h3>
|
||||||
<ul class="scenarios">
|
<ul class="scenarios">
|
||||||
|
|||||||
@@ -79,6 +79,17 @@ function methods(figures: { figure: { data: unknown[] } }[]): string[] {
|
|||||||
return [...new Set(names.filter((n): n is string => !!n))];
|
return [...new Set(names.filter((n): n is string => !!n))];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function modelInputs(value: string | undefined): Record<string, unknown> | undefined {
|
||||||
|
if (!value) return undefined;
|
||||||
|
try {
|
||||||
|
const parsed: unknown = JSON.parse(value);
|
||||||
|
return parsed && typeof parsed === 'object' && !Array.isArray(parsed)
|
||||||
|
? parsed as Record<string, unknown> : undefined;
|
||||||
|
} catch {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-paciente',
|
selector: 'app-paciente',
|
||||||
imports: [
|
imports: [
|
||||||
@@ -348,6 +359,7 @@ export class Paciente {
|
|||||||
version: Number(/v(\d+)$/.exec(r.method?.text ?? '')?.[1] ?? 0),
|
version: Number(/v(\d+)$/.exec(r.method?.text ?? '')?.[1] ?? 0),
|
||||||
index: r.occurrenceDateTime ?? '',
|
index: r.occurrenceDateTime ?? '',
|
||||||
measure: ext(r, 'prediction-measure')?.valueCode,
|
measure: ext(r, 'prediction-measure')?.valueCode,
|
||||||
|
inputs: modelInputs(ext(r, 'model-inputs')?.valueString),
|
||||||
// the clinical scenarios of the model's report she falls in
|
// the clinical scenarios of the model's report she falls in
|
||||||
scenarios: (r.extension ?? [])
|
scenarios: (r.extension ?? [])
|
||||||
.filter((e) => e.url === EXT + 'escenario-clinico')
|
.filter((e) => e.url === EXT + 'escenario-clinico')
|
||||||
|
|||||||
@@ -94,4 +94,11 @@ describe('survival scales', () => {
|
|||||||
expect(g.scales[0].risk?.low).toBeCloseTo(0.7);
|
expect(g.scales[0].risk?.low).toBeCloseTo(0.7);
|
||||||
expect(g.scales[0].risk?.high).toBeCloseTo(0.9);
|
expect(g.scales[0].risk?.high).toBeCloseTo(0.9);
|
||||||
});
|
});
|
||||||
|
it('keeps the inputs attached to the estimate and leaves old estimates without them', () => {
|
||||||
|
const inputs = { age_group: '45-54', cytology: 'HSIL+', hpv: 'positive' };
|
||||||
|
expect(survivalGroups([{ index: '2026-01-01', predictions: [at(1, 0.2)], inputs }])[0].inputs)
|
||||||
|
.toEqual(inputs);
|
||||||
|
expect(riskGroups([{ text: 'Riesgo', index: '2026-01-01', predictions: [at(5, 0.2)] }])[0].inputs)
|
||||||
|
.toBeUndefined();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -49,13 +49,16 @@ export interface RiskGroup {
|
|||||||
scenario?: string;
|
scenario?: string;
|
||||||
index?: string;
|
index?: string;
|
||||||
survival?: boolean;
|
survival?: boolean;
|
||||||
|
inputs?: Record<string, unknown>;
|
||||||
scales: { label: string; risk?: Prediction }[];
|
scales: { label: string; risk?: Prediction }[];
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Stored survival-model probabilities are mortality: complement them to obtain S(t). */
|
/** Stored survival-model probabilities are mortality: complement them to obtain S(t). */
|
||||||
export function survivalGroups(models: { index: string; predictions: Prediction[] }[]): RiskGroup[] {
|
export function survivalGroups(models: { index: string; predictions: Prediction[];
|
||||||
|
scenarios?: string[]; inputs?: Record<string, unknown> }[]): RiskGroup[] {
|
||||||
return models.map((m) => ({
|
return models.map((m) => ({
|
||||||
title: 'Supervivencia', index: m.index, survival: true,
|
title: 'Supervivencia', index: m.index, survival: true, inputs: m.inputs,
|
||||||
|
scenario: m.scenarios?.join(' · '),
|
||||||
scales: m.predictions.flatMap((p) => {
|
scales: m.predictions.flatMap((p) => {
|
||||||
const v = horizon(m.predictions, p.years);
|
const v = horizon(m.predictions, p.years);
|
||||||
return v ? [{ label: `Supervivencia a ${p.years} ${p.years === 1 ? 'año' : 'años'}`,
|
return v ? [{ label: `Supervivencia a ${p.years} ${p.years === 1 ? 'año' : 'años'}`,
|
||||||
@@ -80,7 +83,8 @@ export function titleParts(text: string): { title: string; scenario?: string } {
|
|||||||
/** The scales the page draws: both horizons of every model, or, with no model, both horizons
|
/** The scales the page draws: both horizons of every model, or, with no model, both horizons
|
||||||
* unavailable. */
|
* unavailable. */
|
||||||
export function riskGroups(
|
export function riskGroups(
|
||||||
models: { text: string; index: string; predictions: Prediction[] }[],
|
models: { text: string; index: string; predictions: Prediction[];
|
||||||
|
inputs?: Record<string, unknown> }[],
|
||||||
): RiskGroup[] {
|
): RiskGroup[] {
|
||||||
const scales = (predictions: Prediction[]) =>
|
const scales = (predictions: Prediction[]) =>
|
||||||
HORIZONS.map(([years, label]) => ({ label, risk: horizon(predictions, years) }));
|
HORIZONS.map(([years, label]) => ({ label, risk: horizon(predictions, years) }));
|
||||||
@@ -88,6 +92,7 @@ export function riskGroups(
|
|||||||
? models.map((m) => ({
|
? models.map((m) => ({
|
||||||
...titleParts(m.text),
|
...titleParts(m.text),
|
||||||
index: m.index,
|
index: m.index,
|
||||||
|
inputs: m.inputs,
|
||||||
scales: scales(m.predictions),
|
scales: scales(m.predictions),
|
||||||
}))
|
}))
|
||||||
: [{ scales: scales([]) }];
|
: [{ scales: scales([]) }];
|
||||||
@@ -149,6 +154,20 @@ export function riskGroups(
|
|||||||
{{ g.scenario ? 'Escenario: ' + g.scenario + ' · ' : '' }}Fecha índice {{ g.index }}
|
{{ g.scenario ? 'Escenario: ' + g.scenario + ' · ' : '' }}Fecha índice {{ g.index }}
|
||||||
</p>
|
</p>
|
||||||
}
|
}
|
||||||
|
@if (g.title) {
|
||||||
|
<section>
|
||||||
|
<h4>Factores de riesgo considerados</h4>
|
||||||
|
@if (g.inputs) {
|
||||||
|
<dl>
|
||||||
|
@for (item of entries(g.inputs); track item[0]) {
|
||||||
|
<div><dt>{{ inputName(item[0]) }}</dt><dd>{{ inputValue(item[0], item[1]) }}</dd></div>
|
||||||
|
}
|
||||||
|
</dl>
|
||||||
|
} @else {
|
||||||
|
<p class="muted">Los valores utilizados no están disponibles para esta estimación.</p>
|
||||||
|
}
|
||||||
|
</section>
|
||||||
|
}
|
||||||
}
|
}
|
||||||
`,
|
`,
|
||||||
styles: `
|
styles: `
|
||||||
@@ -235,4 +254,18 @@ export function riskGroups(
|
|||||||
})
|
})
|
||||||
export class RiskScales {
|
export class RiskScales {
|
||||||
readonly groups = input.required<RiskGroup[]>();
|
readonly groups = input.required<RiskGroup[]>();
|
||||||
|
protected readonly entries = Object.entries;
|
||||||
|
protected readonly inputName = (name: string) => ({
|
||||||
|
age_group: 'Edad al diagnóstico', cytology: 'Citología', hpv: 'VPH',
|
||||||
|
hpv_positive: 'VPH', hpv_16_18: 'VPH 16/18', referral_grade: 'Referencia',
|
||||||
|
bethesda: 'Citología', hpv_16: 'VPH 16', hpv_18: 'VPH 18',
|
||||||
|
} as Record<string, string>)[name] ?? name;
|
||||||
|
protected readonly inputValue = (name: string, value: unknown) => {
|
||||||
|
if (value === null || value === undefined) return 'No documentado';
|
||||||
|
if (name.startsWith('hpv') && (value === 0 || value === 1 || typeof value === 'boolean'))
|
||||||
|
return value ? 'Positivo' : 'Negativo';
|
||||||
|
if (name.startsWith('hpv') && value === 'positive') return 'Positivo';
|
||||||
|
if (name.startsWith('hpv') && value === 'negative') return 'Negativo';
|
||||||
|
return String(value);
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user