Survival scenario charts on the governance page; breast treatment entity
This commit is contained in:
@@ -9,7 +9,7 @@ import { RequestBuilder } from '../../request-builder';
|
||||
|
||||
|
||||
export interface Conflicts$Params {
|
||||
entity: 'identity' | 'cervical_cytology' | 'cervical_biopsy' | 'mammography' | 'breast_biopsy' | 'clinical_note' | 'death' | 'mchat' | 'ados2' | 'eeg';
|
||||
entity: 'identity' | 'cervical_cytology' | 'cervical_biopsy' | 'mammography' | 'breast_biopsy' | 'breast_treatment' | 'clinical_note' | 'death' | 'mchat' | 'ados2' | 'eeg';
|
||||
}
|
||||
|
||||
export function conflicts(http: HttpClient, rootUrl: string, params: Conflicts$Params, context?: HttpContext): Observable<StrictHttpResponse<Array<{
|
||||
|
||||
@@ -9,7 +9,7 @@ import { RequestBuilder } from '../../request-builder';
|
||||
|
||||
|
||||
export interface Held$Params {
|
||||
entity: 'identity' | 'cervical_cytology' | 'cervical_biopsy' | 'mammography' | 'breast_biopsy' | 'clinical_note' | 'death' | 'mchat' | 'ados2' | 'eeg';
|
||||
entity: 'identity' | 'cervical_cytology' | 'cervical_biopsy' | 'mammography' | 'breast_biopsy' | 'breast_treatment' | 'clinical_note' | 'death' | 'mchat' | 'ados2' | 'eeg';
|
||||
}
|
||||
|
||||
export function held(http: HttpClient, rootUrl: string, params: Held$Params, context?: HttpContext): Observable<StrictHttpResponse<Array<{
|
||||
|
||||
@@ -14,7 +14,7 @@ import { Position } from '../models/position';
|
||||
export interface Extract {
|
||||
column: string;
|
||||
concept_map?: (string | null);
|
||||
entity: 'identity' | 'cervical_cytology' | 'cervical_biopsy' | 'mammography' | 'breast_biopsy' | 'clinical_note' | 'death' | 'mchat' | 'ados2' | 'eeg';
|
||||
entity: 'identity' | 'cervical_cytology' | 'cervical_biopsy' | 'mammography' | 'breast_biopsy' | 'breast_treatment' | 'clinical_note' | 'death' | 'mchat' | 'ados2' | 'eeg';
|
||||
formats?: {
|
||||
[key: string]: string;
|
||||
};
|
||||
|
||||
@@ -11,7 +11,7 @@ import { Position } from '../models/position';
|
||||
export interface Fhir {
|
||||
column?: string;
|
||||
concept_map?: (string | null);
|
||||
entity: 'identity' | 'cervical_cytology' | 'cervical_biopsy' | 'mammography' | 'breast_biopsy' | 'clinical_note' | 'death' | 'mchat' | 'ados2' | 'eeg';
|
||||
entity: 'identity' | 'cervical_cytology' | 'cervical_biopsy' | 'mammography' | 'breast_biopsy' | 'breast_treatment' | 'clinical_note' | 'death' | 'mchat' | 'ados2' | 'eeg';
|
||||
id: string;
|
||||
inputs?: Array<string>;
|
||||
kind?: 'fhir';
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
/* Code generated by ng-openapi-gen DO NOT EDIT. */
|
||||
|
||||
export interface Rejection {
|
||||
entity: 'identity' | 'cervical_cytology' | 'cervical_biopsy' | 'mammography' | 'breast_biopsy' | 'clinical_note' | 'death' | 'mchat' | 'ados2' | 'eeg';
|
||||
entity: 'identity' | 'cervical_cytology' | 'cervical_biopsy' | 'mammography' | 'breast_biopsy' | 'breast_treatment' | 'clinical_note' | 'death' | 'mchat' | 'ados2' | 'eeg';
|
||||
reason: string;
|
||||
record: string;
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ import { Position } from '../models/position';
|
||||
* one `link` node among the inputs. Rule breaks are held for review.
|
||||
*/
|
||||
export interface Target {
|
||||
entity: 'identity' | 'cervical_cytology' | 'cervical_biopsy' | 'mammography' | 'breast_biopsy' | 'clinical_note' | 'death' | 'mchat' | 'ados2' | 'eeg';
|
||||
entity: 'identity' | 'cervical_cytology' | 'cervical_biopsy' | 'mammography' | 'breast_biopsy' | 'breast_treatment' | 'clinical_note' | 'death' | 'mchat' | 'ados2' | 'eeg';
|
||||
id: string;
|
||||
inputs?: Array<string>;
|
||||
kind?: 'target';
|
||||
|
||||
@@ -13,6 +13,29 @@ describe('governance figures', () => {
|
||||
expect((found.figure.data[2] as any).error_y.array[0]).toBeCloseTo(0.05);
|
||||
});
|
||||
|
||||
it("draws each survival scenario after the cohort's curves, titled with its deaths", () => {
|
||||
const scenario = {
|
||||
escenario: 'HER2+ · ≥60 años · estadio III–IV (Alto)',
|
||||
n: 1142,
|
||||
fallecidos: 308,
|
||||
horizons_months: [6, 12, 18],
|
||||
km: { months: [0, 12], S: [1, 0.8], low: [1, 0.75], high: [1, 0.85] },
|
||||
weibull: { t: [0, 12], S: [1, 0.8] },
|
||||
weibull_fractional: { t: [0, 12], S: [1, 0.79] },
|
||||
points: { COMB: { S: [0.86, 0.8, 0.74], low: [0.85, 0.78, 0.72], high: [0.88, 0.82, 0.76] } },
|
||||
};
|
||||
const found = interpretabilityFigures({
|
||||
kind: 'curves',
|
||||
curves: [{ name: 'Kaplan-Meier', months: [0], survival: [1], low: [1], high: [1] }],
|
||||
predicted: { name: 'Modelo', months: [6], survival: [0.9], low: [0.8], high: [0.95] },
|
||||
escenarios: [scenario],
|
||||
});
|
||||
expect(found.length).toBe(2);
|
||||
expect(found[1].title).toContain('fallecidos = 308');
|
||||
expect(found[1].figure.data.length).toBe(5); // band, KM, Weibull, fractional, points
|
||||
expect((found[1].figure.data[4] as any).x).toEqual([6, 12, 18]);
|
||||
});
|
||||
|
||||
it('draws a recurrence scenario: KM band, both Weibulls and the model points', () => {
|
||||
const [found] = interpretabilityFigures({
|
||||
kind: 'scenarios',
|
||||
|
||||
@@ -70,6 +70,15 @@ export function interpretabilityFigures(
|
||||
},
|
||||
},
|
||||
},
|
||||
// Its clinical scenarios, those with enough deaths to draw.
|
||||
...((report['escenarios'] ?? []) as any[]).map((e) =>
|
||||
scenarioFigure(
|
||||
`${e.escenario} (n = ${e.n.toLocaleString('es-MX')}, fallecidos = ${e.fallecidos.toLocaleString('es-MX')})`,
|
||||
e,
|
||||
e.horizons_months,
|
||||
'Supervivencia S(t)',
|
||||
),
|
||||
),
|
||||
];
|
||||
}
|
||||
case 'subgroups':
|
||||
@@ -139,43 +148,16 @@ export function interpretabilityFigures(
|
||||
];
|
||||
}
|
||||
case 'scenarios':
|
||||
return (report['recurrencia']['escenarios'] as any[]).slice(0, 6).map((e) => ({
|
||||
title: `${e.cohorte_nombre} · ${e.escenario} (n = ${e.n}, ${e.recaidas} recaídas)`,
|
||||
figure: {
|
||||
data: [
|
||||
...banded(
|
||||
'Kaplan-Meier (IC 95 %)',
|
||||
{ x: e.km.months, y: e.km.S, low: e.km.low, high: e.km.high },
|
||||
PALETTE[0],
|
||||
),
|
||||
{
|
||||
x: e.weibull.t,
|
||||
y: e.weibull.S,
|
||||
name: 'Weibull',
|
||||
type: 'scatter',
|
||||
mode: 'lines',
|
||||
line: { color: PALETTE[1], dash: 'dot' },
|
||||
},
|
||||
{
|
||||
x: e.weibull_fractional.t,
|
||||
y: e.weibull_fractional.S,
|
||||
name: 'Weibull fraccional',
|
||||
type: 'scatter',
|
||||
mode: 'lines',
|
||||
line: { color: PALETTE[2] },
|
||||
},
|
||||
points(
|
||||
'Modelo (IC 95 % bootstrap)',
|
||||
report['recurrencia']['horizons_months'],
|
||||
e.points.COMB,
|
||||
),
|
||||
],
|
||||
layout: {
|
||||
xaxis: { title: { text: 'Meses desde el diagnóstico' } },
|
||||
yaxis: { title: { text: 'Supervivencia libre de recaída' } },
|
||||
},
|
||||
},
|
||||
}));
|
||||
return (report['recurrencia']['escenarios'] as any[])
|
||||
.slice(0, 6)
|
||||
.map((e) =>
|
||||
scenarioFigure(
|
||||
`${e.cohorte_nombre} · ${e.escenario} (n = ${e.n}, ${e.recaidas} recaídas)`,
|
||||
e,
|
||||
report['recurrencia']['horizons_months'],
|
||||
'Supervivencia libre de recaída',
|
||||
),
|
||||
);
|
||||
case 'age_curves': {
|
||||
// The metric's own curve; a topography has only electrodes: its first one.
|
||||
const value = report['curves']['value'] ?? Object.values(report['curves'])[0];
|
||||
@@ -228,6 +210,49 @@ export function interpretabilityFigures(
|
||||
}
|
||||
}
|
||||
|
||||
/** One clinical scenario: Kaplan-Meier with its band, the classic and fractional Weibull,
|
||||
* and the model's points with their bootstrap band. */
|
||||
function scenarioFigure(
|
||||
title: string,
|
||||
e: any,
|
||||
horizons: number[],
|
||||
yTitle: string,
|
||||
): { title: string; figure: Figure } {
|
||||
return {
|
||||
title,
|
||||
figure: {
|
||||
data: [
|
||||
...banded(
|
||||
'Kaplan-Meier (IC 95 % Greenwood)',
|
||||
{ x: e.km.months, y: e.km.S, low: e.km.low, high: e.km.high },
|
||||
PALETTE[0],
|
||||
),
|
||||
{
|
||||
x: e.weibull.t,
|
||||
y: e.weibull.S,
|
||||
name: 'Weibull',
|
||||
type: 'scatter',
|
||||
mode: 'lines',
|
||||
line: { color: PALETTE[1] },
|
||||
},
|
||||
{
|
||||
x: e.weibull_fractional.t,
|
||||
y: e.weibull_fractional.S,
|
||||
name: 'Weibull fraccional',
|
||||
type: 'scatter',
|
||||
mode: 'lines',
|
||||
line: { color: PALETTE[2], dash: 'dash' },
|
||||
},
|
||||
points('LR + HBN combinado (IC 95 % bootstrap)', horizons, e.points.COMB),
|
||||
],
|
||||
layout: {
|
||||
xaxis: { title: { text: 'Meses desde el diagnóstico' } },
|
||||
yaxis: { title: { text: yTitle } },
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
function points(
|
||||
name: string,
|
||||
x: number[],
|
||||
|
||||
@@ -32,6 +32,7 @@ const ENTITIES: Record<Entity, string> = {
|
||||
identity: 'Identidad',
|
||||
mammography: 'Mastografía',
|
||||
breast_biopsy: 'Biopsia de mama',
|
||||
breast_treatment: 'Tratamiento de cáncer de mama',
|
||||
mchat: 'M-CHAT',
|
||||
ados2: 'ADOS-2',
|
||||
eeg: 'Electroencefalograma',
|
||||
|
||||
Reference in New Issue
Block a user