Mostrar la elegibilidad CaCu solo cuando la paciente no es elegible

This commit is contained in:
2026-12-02 19:04:00 -06:00
parent 370da43695
commit a4cc80fbe2
4 changed files with 74 additions and 22 deletions
+12 -11
View File
@@ -27,13 +27,9 @@ import type { Parameters as FhirParameters } from 'fhir/r4';
import { firstValueFrom } from 'rxjs';
import { ApiConfiguration } from '../api/api-configuration';
import { ANTECEDENTS, Fact, group, split } from './record-groups';
import {
Eligibility,
eligibilityFailure,
eligibilityView,
type EligibilityState,
} from './eligibility';
import { eligibilityFailure, eligibilityView, type EligibilityState } from './eligibility';
import { referenceView, ReferenceRisk, ReferenceView } from './reference-risk';
import { ineligibility } from './ineligibility';
import { parseSeries, RiskSeries, Series } from './risk-series';
import { curveFigure, curveText } from './risk-curve';
import { isRiskModel, riskGroups, riskScales, RiskScales } from './risk-scales';
@@ -96,7 +92,6 @@ function methods(figures: { figure: { data: unknown[] } }[]): string[] {
Plot,
RiskScales,
ReferenceRisk,
Eligibility,
RiskSeries,
Stages,
],
@@ -164,14 +159,21 @@ export class Paciente {
});
protected readonly cutoff = computed(() => this.corte() ?? new Date().toLocaleDateString('sv'));
protected readonly age = computed(() => ageAt(this.patient()?.birthDate, this.cutoff()));
/** Why she has no risk estimate; nothing when she is eligible. Only while the backend gives
* no decision (failure, gold not updated) is the hysterectomy of her record held against it. */
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();
const state = this.eligibility();
if (state.kind === 'evaluated' || state.kind === 'none') {
const status = (patient && ext(patient, 'follow-up-status')?.valueCoding?.code) ?? '';
return ineligibility(state, status, index);
}
const recorded = patient && ext(patient, 'first-hysterectomy-recorded')?.valueDate;
return recorded && recorded <= index
? `Sin estimación de riesgo por antecedente de histerectomía registrado el ${recorded}.`
? `No disponible por: histerectomía registrada el ${recorded}.`
: undefined;
});
/** CaCu: the route of the cytology she was opened at, else of her latest, by the cut-off. */
@@ -223,8 +225,7 @@ export class Paciente {
/** CaCu: the eligibility the backend publishes for each indexed visit (`$eligibility`). A failure is a
* state of the section, never an eligibility; a new patient starts from nothing (no earlier answer). */
private readonly eligibilityData = resource({
params: () =>
this.domain() === 'cacu' ? { id: this.id(), cutoff: this.corte() } : undefined,
params: () => (this.domain() === 'cacu' ? { id: this.id(), cutoff: this.corte() } : undefined),
loader: async ({ params }): Promise<EligibilityState> => {
try {
const answer = await this.api.invoke(cacuEligibility, {