diff --git a/src/app/paciente/paciente.html b/src/app/paciente/paciente.html
index 8ed9910..1c5a653 100644
--- a/src/app/paciente/paciente.html
+++ b/src/app/paciente/paciente.html
@@ -566,6 +566,10 @@
} @else if (domain() === 'cacu') {
No disponible: el informe no contiene la curva para esta combinación.
+
+ Métodos
+ No hay un método publicado para esta combinación.
+
} @else if (survival.value(); as s) {
Escenario clínico de la paciente
diff --git a/src/app/paciente/paciente.ts b/src/app/paciente/paciente.ts
index 3b79aca..dbb0199 100644
--- a/src/app/paciente/paciente.ts
+++ b/src/app/paciente/paciente.ts
@@ -79,6 +79,17 @@ function methods(figures: { figure: { data: unknown[] } }[]): string[] {
return [...new Set(names.filter((n): n is string => !!n))];
}
+function modelInputs(value: string | undefined): Record | undefined {
+ if (!value) return undefined;
+ try {
+ const parsed: unknown = JSON.parse(value);
+ return parsed && typeof parsed === 'object' && !Array.isArray(parsed)
+ ? parsed as Record : undefined;
+ } catch {
+ return undefined;
+ }
+}
+
@Component({
selector: 'app-paciente',
imports: [
@@ -348,6 +359,7 @@ export class Paciente {
version: Number(/v(\d+)$/.exec(r.method?.text ?? '')?.[1] ?? 0),
index: r.occurrenceDateTime ?? '',
measure: ext(r, 'prediction-measure')?.valueCode,
+ inputs: modelInputs(ext(r, 'model-inputs')?.valueString),
// the clinical scenarios of the model's report she falls in
scenarios: (r.extension ?? [])
.filter((e) => e.url === EXT + 'escenario-clinico')
diff --git a/src/app/paciente/risk-scales.spec.ts b/src/app/paciente/risk-scales.spec.ts
index 63503f0..73d3437 100644
--- a/src/app/paciente/risk-scales.spec.ts
+++ b/src/app/paciente/risk-scales.spec.ts
@@ -94,4 +94,11 @@ describe('survival scales', () => {
expect(g.scales[0].risk?.low).toBeCloseTo(0.7);
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();
+ });
});
diff --git a/src/app/paciente/risk-scales.ts b/src/app/paciente/risk-scales.ts
index 7bea171..f500bd7 100644
--- a/src/app/paciente/risk-scales.ts
+++ b/src/app/paciente/risk-scales.ts
@@ -49,13 +49,16 @@ export interface RiskGroup {
scenario?: string;
index?: string;
survival?: boolean;
+ inputs?: Record;
scales: { label: string; risk?: Prediction }[];
}
/** 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 }[]): RiskGroup[] {
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) => {
const v = horizon(m.predictions, p.years);
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
* unavailable. */
export function riskGroups(
- models: { text: string; index: string; predictions: Prediction[] }[],
+ models: { text: string; index: string; predictions: Prediction[];
+ inputs?: Record }[],
): RiskGroup[] {
const scales = (predictions: Prediction[]) =>
HORIZONS.map(([years, label]) => ({ label, risk: horizon(predictions, years) }));
@@ -88,6 +92,7 @@ export function riskGroups(
? models.map((m) => ({
...titleParts(m.text),
index: m.index,
+ inputs: m.inputs,
scales: scales(m.predictions),
}))
: [{ scales: scales([]) }];
@@ -149,6 +154,20 @@ export function riskGroups(
{{ g.scenario ? 'Escenario: ' + g.scenario + ' · ' : '' }}Fecha índice {{ g.index }}
}
+ @if (g.title) {
+
+ Factores de riesgo considerados
+ @if (g.inputs) {
+
+ @for (item of entries(g.inputs); track item[0]) {
+ - {{ inputName(item[0]) }}
- {{ inputValue(item[0], item[1]) }}
+ }
+
+ } @else {
+ Los valores utilizados no están disponibles para esta estimación.
+ }
+
+ }
}
`,
styles: `
@@ -235,4 +254,18 @@ export function riskGroups(
})
export class RiskScales {
readonly groups = input.required();
+ 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)[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);
+ };
}