Compare commits

..

2 Commits

Author SHA1 Message Date
Angel Capetillo Zavala f119ba048a Simplify CaCu distribution descriptions 2026-12-02 14:09:02 -06:00
edgar 9ae8254dee Mostrar el motivo de exclusión en la ficha CaCu 2026-12-02 09:35:25 -06:00
5 changed files with 63 additions and 43 deletions
+7 -2
View File
@@ -64,6 +64,10 @@ test('indicadores cacu: its sections in order, each card read one mode at a time
});
// each card has no toggle of its own: the selector drives both
await expect(readings.getByRole('radio')).toHaveCount(0);
// no long description beside the bars: the cards read from their title, note and legend
await expect(readings).not.toContainText(
/Cada barra|Cada paciente cuenta una vez|«Detección inicial»|una barra vacía|«Positivo»/,
);
await expect(
readings
.locator('.group')
@@ -286,12 +290,13 @@ for (const card of ['cytology', 'genotype'] as const) {
});
}
test('rondas (simulado): the genotype card never shows the incomplete positives, and says where they went', async ({
test('rondas (simulado): the genotype card never shows the incomplete positives, and carries no long description', async ({
page,
}) => {
const { card, view } = await withRounds(page, 'as-is');
const readings = card(TITLES.genotype);
await expect(readings).toContainText('«Positivo»');
await expect(readings).not.toContainText('«Positivo»');
await expect(readings).not.toContainText('Cada barra');
await expect(readings.getByRole('rowheader')).not.toContainText([
'Otro de alto riesgo',
'incompleto',
+31
View File
@@ -117,6 +117,37 @@ async function open(page: Page, url: string) {
await expect(historial(page)).toBeVisible({ timeout: 120_000 });
await expect(page.locator('app-loading')).toHaveCount(0, { timeout: 60_000 });
}
test('ficha (simulado): states why a hysterectomy makes this risk assessment unavailable', async ({
page,
}) => {
const { url, sample } = await firstRecord(page);
const previousDay = plus(sample, -1);
await page.route('**/api/cacu/fhir/Patient/*', async (route) => {
const response = await route.fetch();
const patient = await response.json();
patient.extension = [
...(patient.extension ?? []),
{ url: EXT + 'first-hysterectomy-recorded', valueDate: sample },
];
await route.fulfill({ response, json: patient });
});
await withRisks(page, [risk('past', 'Modelo v1', 'cacu.cin2_pim', previousDay, [[5, 0.2]])]);
await open(page, url);
await expect(
page.getByText('Sin estimación de riesgo por antecedente de histerectomía', {
exact: false,
}),
).toBeVisible();
await expect(page.locator('app-risk-scales')).toHaveCount(0);
const historical = new URL(url, 'http://example.test');
historical.searchParams.set('citologia', previousDay);
await open(page, historical.pathname + historical.search);
await expect(page.locator('app-risk-scales')).toBeVisible();
});
/** Where a scale draws its marker, in % of the bar, and the figure it prints. */
async function drawn(scaleBox: Locator) {
const marker = scaleBox.locator('.risk-marker');
+5 -37
View File
@@ -85,14 +85,6 @@ const BY_STATUS = 'Por estatus de seguimiento';
const BY_ROUND = 'Por detección inicial y subsecuente';
const AGE_GROUPS = ['<25', '25-34', '35-44', '45-54', '55-64', '65+', 'no_data'];
const STATUSES = ['pre_colposcopy', 'post_colposcopy', 'post_treatment', 'case', 'no_data'];
const ROUND_MEANING =
'«Detección inicial»: primera vez en la vida y sin colposcopía ni tratamiento a la toma. ' +
'«Detección subsecuente»: con detección previa registrada, o ya con colposcopía o tratamiento a la toma. ' +
'«Sin dato»: sin detección previa registrada y sin colposcopía ni tratamiento. ';
const CYTOLOGY_BARS =
'Cada barra suma 100 % de las pacientes del grupo con resultado citológico (n indica cuántas son).';
const POSITIVE_MEANING =
'«Positivo»: VPH de alto riesgo positivo con los genotipos 16 y 18 reportados negativos; los positivos para 16, 18 o ambos se muestran aparte.';
/** HPV categories the cards do not draw (their reports stay in the total and the percentages). */
const HPV_HIDDEN = {
codes: ['positive_incomplete', 'inconsistent', 'no_result'],
@@ -104,13 +96,12 @@ const groupViews = (
measure: string,
catalog: { code: string; label: string; color: string }[],
unit: string,
caption: { age: string; status: string; round: string },
more: { ofAll?: boolean; hidden?: { codes: string[]; unit: string } } = {},
): Mode[] =>
[
{ label: BY_AGE, stratum: 'age_group', order: AGE_GROUPS, caption: caption.age },
{ label: BY_STATUS, stratum: 'follow_up_status', order: STATUSES, caption: caption.status },
{ label: BY_ROUND, stratum: 'round', order: ROUNDS, caption: caption.round, complete: true },
{ label: BY_AGE, stratum: 'age_group', order: AGE_GROUPS },
{ label: BY_STATUS, stratum: 'follow_up_status', order: STATUSES },
{ label: BY_ROUND, stratum: 'round', order: ROUNDS, complete: true },
].map((v) => ({
kind: 'grouped' as const,
measure,
@@ -256,19 +247,7 @@ export const CACU: Page = {
note: 'Pacientes, por su última muestra válida del periodo.',
modes: [
{ kind: 'counts', label: GENERAL, measure: 'CACU_EU7', catalog: CYTOLOGY.categories },
...groupViews('CACU_EU7', CYTOLOGY.categories, 'pacientes', {
age:
'Cada paciente cuenta una vez, con su última muestra válida del periodo; la edad es la de la paciente al inicio del periodo. ' +
CYTOLOGY_BARS,
status:
'Cada paciente cuenta una vez, con su última muestra válida del periodo; el estatus es el de la paciente al inicio del periodo. ' +
CYTOLOGY_BARS,
round:
'Cada paciente cuenta una vez, con su última muestra válida del periodo; la detección es la de esa muestra (fecha de toma). ' +
ROUND_MEANING +
CYTOLOGY_BARS +
' Si hay pacientes en «Sin dato», una barra vacía significa que no hay pacientes clasificadas en esa detección según la información disponible.',
}),
...groupViews('CACU_EU7', CYTOLOGY.categories, 'pacientes'),
],
},
{
@@ -283,19 +262,8 @@ export const CACU: Page = {
measure: 'CACU_VPH_GENOTIPO',
catalog: HPV,
hidden: HPV_HIDDEN,
caption: POSITIVE_MEANING,
},
...groupViews(
'CACU_VPH_GENOTIPO',
HPV,
'reportes',
{
age: `Cada barra son los reportes de VPH del grupo de edad de la paciente al inicio del periodo. ${POSITIVE_MEANING}`,
status: `Cada barra son los reportes de VPH del estatus de la paciente al inicio del periodo. ${POSITIVE_MEANING}`,
round: `Cada barra son los reportes de VPH de las muestras de esa detección (fecha de toma). ${ROUND_MEANING}Si hay reportes en «Sin dato», una barra vacía significa que no hay reportes de muestras clasificadas en esa detección según la información disponible. ${POSITIVE_MEANING}`,
},
{ ofAll: true, hidden: HPV_HIDDEN },
),
...groupViews('CACU_VPH_GENOTIPO', HPV, 'reportes', { ofAll: true, hidden: HPV_HIDDEN }),
],
},
{
+8 -4
View File
@@ -258,9 +258,13 @@
><mat-card-title>Riesgos y recomendaciones</mat-card-title></mat-card-header
>
<mat-card-content>
<app-risk-scales [groups]="groups()" />
@if (reference.value(); as ref) {
<app-reference-risk [view]="ref" />
@if (riskExclusion(); as reason) {
<p role="status">{{ reason }}</p>
} @else {
<app-risk-scales [groups]="groups()" />
@if (reference.value(); as ref) {
<app-reference-risk [view]="ref" />
}
}
@if (models().length) {
<table class="plain">
@@ -303,7 +307,7 @@
</ul>
<app-plot [figure]="curve()" [height]="300" />
</details>
} @else {
} @else if (!riskExclusion()) {
<p class="muted">Sin evaluación de un modelo en producción.</p>
}
</mat-card-content>
+12
View File
@@ -148,6 +148,16 @@ export class Paciente {
});
protected readonly cutoff = computed(() => this.corte() ?? new Date().toLocaleDateString('sv'));
protected readonly age = computed(() => ageAt(this.patient()?.birthDate, this.cutoff()));
protected readonly riskExclusion = computed(() => {
if (this.domain() !== 'cacu') return undefined;
const patient = this.patient();
const recorded = patient && ext(patient, 'first-hysterectomy-recorded')?.valueDate;
const sample = this.citologia()?.slice(0, 10);
const index = sample && sample < this.cutoff() ? sample : this.cutoff();
return recorded && recorded <= index
? `Sin estimación de riesgo por antecedente de histerectomía registrado el ${recorded}.`
: undefined;
});
/** CaCu: the route of the cytology she was opened at, else of her latest, by the cut-off. */
protected readonly stages = computed(() => {
const cytologies = (this.data.value()?.reports ?? []).filter(
@@ -207,6 +217,7 @@ export class Paciente {
['Estatus de seguimiento', this.status()],
['Fecha de corte', this.cutoff()],
];
if (this.riskExclusion()) facts.push(['Evaluación de riesgo', this.riskExclusion()]);
const sheets = recordSheets(
facts,
this.stages() ?? [],
@@ -270,6 +281,7 @@ export class Paciente {
protected readonly antecedents = ANTECEDENTS;
/** One model's latest risk assessment per model. */
protected readonly models = computed(() => {
if (this.riskExclusion()) return [];
const latest = new Map<string, RiskAssessment>();
for (const r of this.data.value()?.risks ?? []) {
const key = code(r.method) ?? '';