Mostrar la elegibilidad CaCu solo cuando la paciente no es elegible
This commit is contained in:
@@ -0,0 +1,31 @@
|
|||||||
|
import type { EligibilityState, Visit } from './eligibility';
|
||||||
|
import { ineligibility } from './ineligibility';
|
||||||
|
|
||||||
|
const visit = (indexDate: string, ...reasons: string[]): Visit => ({
|
||||||
|
indexDate,
|
||||||
|
eligible: !reasons.length,
|
||||||
|
reasons: reasons.map((text) => ({ code: text, text })),
|
||||||
|
});
|
||||||
|
const state: EligibilityState = {
|
||||||
|
kind: 'evaluated',
|
||||||
|
groups: [
|
||||||
|
{
|
||||||
|
code: 'pre_colposcopy',
|
||||||
|
text: 'Precolposcopia',
|
||||||
|
visits: [visit('2025-01-01', 'Histerectomía previa al índice'), visit('2024-01-01')],
|
||||||
|
},
|
||||||
|
{ code: 'post_treatment', text: 'Postratamiento', visits: [visit('2025-01-01', 'Otro')] },
|
||||||
|
],
|
||||||
|
};
|
||||||
|
|
||||||
|
describe('ineligibility', () => {
|
||||||
|
it('speaks only when she is not eligible in her own scenario', () => {
|
||||||
|
expect(ineligibility(state, 'pre_colposcopy', '2025-06-01')).toBe(
|
||||||
|
'No disponible por: Histerectomía previa al índice.',
|
||||||
|
);
|
||||||
|
expect(ineligibility(state, 'pre_colposcopy', '2024-06-01')).toBeUndefined();
|
||||||
|
expect(ineligibility(state, 'post_colposcopy', '2025-06-01')).toBeUndefined();
|
||||||
|
expect(ineligibility(state, 'case', '2025-06-01')).toBeUndefined();
|
||||||
|
expect(ineligibility({ kind: 'error' }, 'pre_colposcopy', '2025-06-01')).toBeUndefined();
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
import type { EligibilityState } from './eligibility';
|
||||||
|
|
||||||
|
/** The `$eligibility` scenarios that stand for each follow-up status, the first that has a
|
||||||
|
* visit speaking for her. A case has no disease-risk estimate to be eligible for. */
|
||||||
|
const SCENARIOS: Record<string, string[]> = {
|
||||||
|
pre_colposcopy: ['pre_colposcopy', 'surveillance'],
|
||||||
|
post_colposcopy: ['post_colposcopy'],
|
||||||
|
post_treatment: ['post_treatment'],
|
||||||
|
};
|
||||||
|
|
||||||
|
/** What the risk section says when she is not eligible in her clinical scenario, from its latest
|
||||||
|
* visit indexed by `day`; nothing when she is eligible or the backend has no visit of it. */
|
||||||
|
export function ineligibility(
|
||||||
|
state: EligibilityState,
|
||||||
|
status: string,
|
||||||
|
day: string,
|
||||||
|
): string | undefined {
|
||||||
|
if (state.kind !== 'evaluated') return undefined;
|
||||||
|
for (const scenario of SCENARIOS[status] ?? []) {
|
||||||
|
// visits come latest first
|
||||||
|
const latest = state.groups
|
||||||
|
.find((g) => g.code === scenario)
|
||||||
|
?.visits.find((v) => v.indexDate <= day);
|
||||||
|
if (latest) {
|
||||||
|
return latest.eligible
|
||||||
|
? undefined
|
||||||
|
: `No disponible por: ${latest.reasons.map((r) => r.text).join('; ')}.`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
@@ -315,17 +315,6 @@
|
|||||||
}
|
}
|
||||||
</mat-card-content>
|
</mat-card-content>
|
||||||
</mat-card>
|
</mat-card>
|
||||||
@if (domain() === 'cacu') {
|
|
||||||
<mat-card appearance="outlined" class="wide" data-section="elegibilidad">
|
|
||||||
<mat-card-header
|
|
||||||
><mat-card-title>Elegibilidad por escenario clínico</mat-card-title></mat-card-header
|
|
||||||
>
|
|
||||||
<mat-card-content>
|
|
||||||
<app-eligibility [state]="eligibility()" />
|
|
||||||
</mat-card-content>
|
|
||||||
</mat-card>
|
|
||||||
}
|
|
||||||
|
|
||||||
@if (domain() === 'tea') {
|
@if (domain() === 'tea') {
|
||||||
<mat-card appearance="outlined" class="wide" data-section="tea">
|
<mat-card appearance="outlined" class="wide" data-section="tea">
|
||||||
<mat-card-header><mat-card-title>ADOS-2</mat-card-title></mat-card-header>
|
<mat-card-header><mat-card-title>ADOS-2</mat-card-title></mat-card-header>
|
||||||
|
|||||||
@@ -27,13 +27,9 @@ import type { Parameters as FhirParameters } from 'fhir/r4';
|
|||||||
import { firstValueFrom } from 'rxjs';
|
import { firstValueFrom } from 'rxjs';
|
||||||
import { ApiConfiguration } from '../api/api-configuration';
|
import { ApiConfiguration } from '../api/api-configuration';
|
||||||
import { ANTECEDENTS, Fact, group, split } from './record-groups';
|
import { ANTECEDENTS, Fact, group, split } from './record-groups';
|
||||||
import {
|
import { eligibilityFailure, eligibilityView, type EligibilityState } from './eligibility';
|
||||||
Eligibility,
|
|
||||||
eligibilityFailure,
|
|
||||||
eligibilityView,
|
|
||||||
type EligibilityState,
|
|
||||||
} from './eligibility';
|
|
||||||
import { referenceView, ReferenceRisk, ReferenceView } from './reference-risk';
|
import { referenceView, ReferenceRisk, ReferenceView } from './reference-risk';
|
||||||
|
import { ineligibility } from './ineligibility';
|
||||||
import { parseSeries, RiskSeries, Series } from './risk-series';
|
import { parseSeries, RiskSeries, Series } from './risk-series';
|
||||||
import { curveFigure, curveText } from './risk-curve';
|
import { curveFigure, curveText } from './risk-curve';
|
||||||
import { isRiskModel, riskGroups, riskScales, RiskScales } from './risk-scales';
|
import { isRiskModel, riskGroups, riskScales, RiskScales } from './risk-scales';
|
||||||
@@ -96,7 +92,6 @@ function methods(figures: { figure: { data: unknown[] } }[]): string[] {
|
|||||||
Plot,
|
Plot,
|
||||||
RiskScales,
|
RiskScales,
|
||||||
ReferenceRisk,
|
ReferenceRisk,
|
||||||
Eligibility,
|
|
||||||
RiskSeries,
|
RiskSeries,
|
||||||
Stages,
|
Stages,
|
||||||
],
|
],
|
||||||
@@ -164,14 +159,21 @@ export class Paciente {
|
|||||||
});
|
});
|
||||||
protected readonly cutoff = computed(() => this.corte() ?? new Date().toLocaleDateString('sv'));
|
protected readonly cutoff = computed(() => this.corte() ?? new Date().toLocaleDateString('sv'));
|
||||||
protected readonly age = computed(() => ageAt(this.patient()?.birthDate, this.cutoff()));
|
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(() => {
|
protected readonly riskExclusion = computed(() => {
|
||||||
if (this.domain() !== 'cacu') return undefined;
|
if (this.domain() !== 'cacu') return undefined;
|
||||||
const patient = this.patient();
|
const patient = this.patient();
|
||||||
const recorded = patient && ext(patient, 'first-hysterectomy-recorded')?.valueDate;
|
|
||||||
const sample = this.citologia()?.slice(0, 10);
|
const sample = this.citologia()?.slice(0, 10);
|
||||||
const index = sample && sample < this.cutoff() ? sample : this.cutoff();
|
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
|
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;
|
: undefined;
|
||||||
});
|
});
|
||||||
/** CaCu: the route of the cytology she was opened at, else of her latest, by the cut-off. */
|
/** 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
|
/** 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). */
|
* state of the section, never an eligibility; a new patient starts from nothing (no earlier answer). */
|
||||||
private readonly eligibilityData = resource({
|
private readonly eligibilityData = resource({
|
||||||
params: () =>
|
params: () => (this.domain() === 'cacu' ? { id: this.id(), cutoff: this.corte() } : undefined),
|
||||||
this.domain() === 'cacu' ? { id: this.id(), cutoff: this.corte() } : undefined,
|
|
||||||
loader: async ({ params }): Promise<EligibilityState> => {
|
loader: async ({ params }): Promise<EligibilityState> => {
|
||||||
try {
|
try {
|
||||||
const answer = await this.api.invoke(cacuEligibility, {
|
const answer = await this.api.invoke(cacuEligibility, {
|
||||||
|
|||||||
Reference in New Issue
Block a user