From 4789282e1712a018e5f9f7cde47909e5db3ba755 Mon Sep 17 00:00:00 2001 From: edgar Date: Fri, 4 Dec 2026 17:49:35 -0600 Subject: [PATCH] =?UTF-8?q?Decir=20a=20qu=C3=A9=20citolog=C3=ADa=20corresp?= =?UTF-8?q?onde=20la=20estimaci=C3=B3n=20y=20comparar=20el=20NCI=20en=20la?= =?UTF-8?q?=20misma?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/paciente/ineligibility.spec.ts | 20 +++++++++++++++++++- src/app/paciente/ineligibility.ts | 24 ++++++++++++++++++++++++ src/app/paciente/paciente.html | 3 +++ src/app/paciente/paciente.ts | 25 ++++++++++++++++++++++--- 4 files changed, 68 insertions(+), 4 deletions(-) diff --git a/src/app/paciente/ineligibility.spec.ts b/src/app/paciente/ineligibility.spec.ts index 226baf7..05e494b 100644 --- a/src/app/paciente/ineligibility.spec.ts +++ b/src/app/paciente/ineligibility.spec.ts @@ -1,5 +1,5 @@ import type { EligibilityState, Visit } from './eligibility'; -import { ineligibility } from './ineligibility'; +import { currency, ineligibility } from './ineligibility'; const visit = (indexDate: string, ...reasons: string[]): Visit => ({ indexDate, @@ -35,3 +35,21 @@ describe('ineligibility', () => { expect(ineligibility({ kind: 'error' }, 'post_treatment', '2025-06-01')).toBe(text); }); }); + +describe('currency', () => { + const pre = [{ model: 'cacu.cin2_pim', index: '2025-01-01' }]; + const post = [{ model: 'cacu.cin2_pim_post_colposcopy', index: '2025-01-01' }]; + + it('dates the estimate and says when there is a later cytology', () => { + expect(currency(pre, ['2025-01-01', '2024-01-01']).note).toBe( + 'Estimación de la citología del 2025-01-01.', + ); + expect(currency(pre, ['2025-06-01', '2025-01-01']).note).toContain('posterior, del 2025-06-01'); + expect(currency([], ['2025-06-01'])).toEqual({}); + }); + + it('shows no post-colposcopy estimate once there is a later visit', () => { + expect(currency(post, ['2025-01-01']).excluded).toBeUndefined(); + expect(currency(post, ['2025-06-01', '2025-01-01']).excluded).toContain('(2025-06-01)'); + }); +}); diff --git a/src/app/paciente/ineligibility.ts b/src/app/paciente/ineligibility.ts index a642cb9..3cb07cf 100644 --- a/src/app/paciente/ineligibility.ts +++ b/src/app/paciente/ineligibility.ts @@ -30,3 +30,27 @@ export function ineligibility( } return undefined; } + +/** Which cytology her estimates speak of, against her latest by the cut-off. After the first + * post-colposcopy visit nothing is evaluated; otherwise a later cytology is only said. */ +export function currency( + estimates: { model: string; index: string }[], + cytologies: string[], +): { sample?: string; excluded?: string; note?: string } { + const sample = estimates.map((e) => e.index.slice(0, 10)).sort().at(-1); + if (!sample) return {}; + const latest = cytologies.map((d) => d.slice(0, 10)).sort().at(-1); + if (!latest || latest <= sample) { + return { sample, note: `Estimación de la citología del ${sample}.` }; + } + if (estimates.some((e) => e.model.includes('post_colposcopy'))) { + return { + sample, + excluded: `No disponible por: hay una citología posterior a la primera visita poscolposcopía (${latest}) y solo se evalúa esa primera visita.`, + }; + } + return { + sample, + note: `Estimación de la citología del ${sample}. Hay una citología posterior, del ${latest}, que no se evalúa.`, + }; +} diff --git a/src/app/paciente/paciente.html b/src/app/paciente/paciente.html index e8cfbba..a2a7517 100644 --- a/src/app/paciente/paciente.html +++ b/src/app/paciente/paciente.html @@ -272,6 +272,9 @@ @if (excluded(); as reason) {

{{ reason }}

} @else { + @if (currency().note; as note) { +

{{ note }}

+ } @if (riskModels().length) {
diff --git a/src/app/paciente/paciente.ts b/src/app/paciente/paciente.ts index be14ee1..311a9e1 100644 --- a/src/app/paciente/paciente.ts +++ b/src/app/paciente/paciente.ts @@ -30,7 +30,7 @@ import { firstValueFrom } from 'rxjs'; import { ApiConfiguration } from '../api/api-configuration'; import { ANTECEDENTS, Fact, group, hpvApart, split } from './record-groups'; import { eligibilityFailure, eligibilityView, type EligibilityState } from './eligibility'; -import { ineligibility } from './ineligibility'; +import { currency, ineligibility } from './ineligibility'; import { parseSeries, RiskSeries, Series } from './risk-series'; import { curveFigure } from './risk-curve'; import { riskGroups, riskScales, RiskScales, survivalGroups } from './risk-scales'; @@ -203,7 +203,21 @@ export class Paciente { return patient ? ext(patient, 'risk-withheld')?.valueString : undefined; }); /** The one criterion she does not meet: nothing else of her risk is then shown. */ - protected readonly excluded = computed(() => this.withheld() ?? this.riskExclusion()); + protected readonly excluded = computed( + () => this.withheld() ?? this.riskExclusion() ?? this.currency().excluded, + ); + /** CaCu: the cytology her estimates speak of, against her latest by the cut-off. */ + protected readonly currency = computed(() => + this.domain() === 'cacu' + ? currency( + this.riskModels(), + (this.data.value()?.reports ?? []) + .filter((r) => code(r.code) === 'cervical_cytology') + .map((r) => r.effectiveDateTime ?? '') + .filter((d) => d && d.slice(0, 10) <= this.cutoff()), + ) + : {}, + ); /** Whether any published series has a point to draw. */ protected readonly hasCurves = computed( () => this.riskSeries.value()?.some((s) => s.points.length > 0) ?? false, @@ -257,7 +271,12 @@ export class Paciente { protected readonly riskSeries = resource({ params: () => this.domain() === 'cacu' - ? { id: this.id(), cutoff: this.corte(), sample: this.citologia() } + ? // the NCI's series speak of the same cytology as the institutional estimate + { + id: this.id(), + cutoff: this.corte(), + sample: this.currency().sample ?? this.citologia(), + } : undefined, loader: async ({ params }): Promise => { try {