Add breast cancer follow-up reports and patient record
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
@let p = summary();
|
||||
<button class="back-button" mat-stroked-button type="button" (click)="back.emit()"><mat-icon aria-hidden="true">arrow_back</mat-icon><span>Regresar</span></button>
|
||||
<header>
|
||||
<h2 #title tabindex="-1">Paciente {{ p.pseudonymId }}</h2>
|
||||
<p>Fecha de corte: {{ p.cutoff }}.</p>
|
||||
<button mat-stroked-button type="button" [disabled]="generating()" (click)="exportPdf()"><mat-icon aria-hidden="true">picture_as_pdf</mat-icon><span>Exportar ficha PDF</span></button>
|
||||
@if (generating()) { <p role="status">Generando PDF…</p> }
|
||||
@if (failed()) { <p role="alert">No se pudo generar el PDF. Intenta nuevamente.</p> }
|
||||
<dl class="summary">
|
||||
<div><dt>Identificador seudónimo</dt><dd>{{ p.pseudonymId }}</dd></div>
|
||||
<div><dt>Grupo de edad</dt><dd>{{ p.ageGroup ?? notAvailable }}</dd></div>
|
||||
<div><dt>Estatus de seguimiento</dt><dd>{{ p.status ?? notAvailable }}</dd></div>
|
||||
<div><dt>Prioridad</dt><dd>{{ p.priority ?? notAvailable }}</dd></div>
|
||||
<div><dt>Días de mastografía a diagnóstico</dt><dd>{{ p.daysMammographyToDiagnosis ?? notAvailable }}</dd></div>
|
||||
</dl>
|
||||
</header>
|
||||
<div class="detail-grid">
|
||||
<mat-card class="mammography-card" appearance="outlined" aria-labelledby="mastografia-title">
|
||||
<mat-card-header><h3 id="mastografia-title">Mastografía</h3></mat-card-header>
|
||||
<mat-card-content>
|
||||
<ul>
|
||||
<li><strong>Última mastografía</strong><span>Categoría BI-RADS: {{ p.birads ?? notAvailable }}</span><span>Fecha: {{ p.mammographyDate ?? notAvailable }}</span></li>
|
||||
</ul>
|
||||
</mat-card-content>
|
||||
</mat-card>
|
||||
<mat-card class="histopathology-card" appearance="outlined" aria-labelledby="histopatologia-title">
|
||||
<mat-card-header><h3 id="histopatologia-title">Histopatología</h3></mat-card-header>
|
||||
<mat-card-content>
|
||||
<ul>
|
||||
<li><strong>Resultado histopatológico</strong><span>Resultado: {{ p.histopathology ?? notAvailable }}</span><span>Fecha de biopsia: {{ p.biopsyDate ?? notAvailable }}</span></li>
|
||||
</ul>
|
||||
</mat-card-content>
|
||||
</mat-card>
|
||||
<mat-card class="prognosis-card" appearance="outlined" aria-labelledby="pronostico-title">
|
||||
<mat-card-header><h3 id="pronostico-title">Pronóstico y recomendaciones</h3></mat-card-header>
|
||||
<mat-card-content>
|
||||
<ul>
|
||||
@for (item of placeholders; track item.key) {
|
||||
<li [attr.data-pronostico]="item.key"><strong>{{ item.label }}</strong><span>{{ prognosisUnavailable }}</span></li>
|
||||
}
|
||||
</ul>
|
||||
<p class="availability">{{ recommendationsUnavailable }}</p>
|
||||
</mat-card-content>
|
||||
</mat-card>
|
||||
</div>
|
||||
@@ -0,0 +1,23 @@
|
||||
:host { display: block; min-width: 0; color: var(--issste-text); overflow-wrap: anywhere; }
|
||||
header { margin-block: 1.5rem; }
|
||||
h2 { margin-block: .5rem 1rem; font-size: 1.65rem; }
|
||||
h3 { margin-block: 0 1rem; font-size: 1.2rem; }
|
||||
.back-button { display: inline-flex; align-items: center; gap: .35rem; min-height: 40px; padding-inline: .65rem; }
|
||||
.back-button mat-icon { width: 1.15rem; height: 1.15rem; font-size: 1.15rem; }
|
||||
.availability { margin-block: .75rem; color: var(--issste-text-secondary); }
|
||||
.summary { display: flex; flex-wrap: wrap; gap: 1.25rem 2rem; }
|
||||
dt { color: var(--issste-text-secondary); font-size: .9rem; }
|
||||
dd { margin: .4rem 0 0; font-weight: 600; }
|
||||
.detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-areas: "mammography histopathology" "prognosis prognosis"; gap: 1rem; align-items: start; }
|
||||
mat-card { min-width: 0; background: var(--issste-surface); color: inherit; border-color: var(--issste-border); }
|
||||
.mammography-card { grid-area: mammography; }
|
||||
.histopathology-card { grid-area: histopathology; }
|
||||
.prognosis-card { grid-area: prognosis; }
|
||||
ul { list-style: none; padding: 0; margin: 0; }
|
||||
li { padding-block: .75rem; border-top: 1px solid var(--issste-border); }
|
||||
li:first-child { border-top: 0; }
|
||||
li span { display: block; margin-top: .4rem; }
|
||||
button { min-height: 44px; color: var(--issste-text); border-color: var(--issste-border); }
|
||||
@media (max-width: 48rem) {
|
||||
.detail-grid { grid-template-columns: minmax(0, 1fr); grid-template-areas: "mammography" "histopathology" "prognosis"; }
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
// Covers CaMa's individual record: how a follow-up row becomes its summary, what the card shows (only fields the list
|
||||
// carries, "No disponible" for the rest, placeholders for recurrence, survival and prognostic factors), and its focus
|
||||
// and back behaviour. Fixture: fixtures/cama_seguimiento.json.
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
import fixtureData from '../../fixtures/cama_seguimiento.json';
|
||||
import { seguimientoTablaResponse } from '../../seguimiento-tabla.service';
|
||||
import { CamaPatientCard } from './cama-patient-card';
|
||||
import { CamaPatientSummary, PROGNOSIS_UNAVAILABLE, RECOMMENDATIONS_UNAVAILABLE, toCamaPatientSummary } from './cama-patient.models';
|
||||
|
||||
const rows = () => seguimientoTablaResponse(structuredClone(fixtureData)).items;
|
||||
const complete = () => rows().find(r => r['biopsia'] !== null && r['dias_mastografia_diagnostico'] !== null)!;
|
||||
const incomplete = () => rows().find(r => r['biopsia'] === null)!;
|
||||
|
||||
describe('Ficha CaMa: resumen', () => {
|
||||
// Fails if a field of the row is mapped to another one or lost on the way to the card.
|
||||
it('reads every field the follow-up row carries', () => {
|
||||
const row = complete();
|
||||
expect(toCamaPatientSummary(row, '2026-10-20')).toEqual({
|
||||
pseudonymId: row['id_seudonimo'], cutoff: '2026-10-20', ageGroup: row['grupo_edad'], status: row['estatus'], priority: row['prioridad'],
|
||||
birads: row['birads'], mammographyDate: row['mastografia_fecha'], histopathology: row['biopsia'], biopsyDate: row['biopsia_fecha'],
|
||||
daysMammographyToDiagnosis: row['dias_mastografia_diagnostico'],
|
||||
});
|
||||
});
|
||||
|
||||
// Fails if a missing value is turned into text or a number (for example 0 days), which would read as clinical data.
|
||||
it('keeps a missing value as null', () => {
|
||||
const summary = toCamaPatientSummary(incomplete(), '2026-10-20')!;
|
||||
expect(summary.histopathology).toBeNull();
|
||||
expect(summary.daysMammographyToDiagnosis).toBeNull();
|
||||
});
|
||||
|
||||
// Fails if a row without an identifier opens a record for nobody.
|
||||
it('has no summary for a row without an identifier', () => {
|
||||
expect(toCamaPatientSummary({ ...complete(), id_seudonimo: null }, '2026-10-20')).toBeNull();
|
||||
expect(toCamaPatientSummary({ ...complete(), id_seudonimo: '' }, '2026-10-20')).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe('Ficha CaMa: componente', () => {
|
||||
let fixture: ReturnType<typeof TestBed.createComponent<CamaPatientCard>>;
|
||||
const root = () => fixture.nativeElement as HTMLElement;
|
||||
function montar(summary: CamaPatientSummary) {
|
||||
fixture = TestBed.createComponent(CamaPatientCard);
|
||||
fixture.componentRef.setInput('summary', summary);
|
||||
fixture.detectChanges();
|
||||
}
|
||||
afterEach(() => fixture?.destroy());
|
||||
|
||||
// Fails if a note or warning line comes back to the record.
|
||||
it('has no note or warning line', () => {
|
||||
montar(toCamaPatientSummary(complete(), '2026-10-20')!);
|
||||
expect(root().querySelector('.note, [role="note"]')).toBeNull();
|
||||
expect(root().textContent).not.toContain('Documento de consulta');
|
||||
});
|
||||
|
||||
// Fails if the card shows something other than what the list carried, or hides the identifier and cut-off.
|
||||
it('shows the summary, the mammography and the histopathology of the row', () => {
|
||||
const row = complete();
|
||||
montar(toCamaPatientSummary(row, '2026-10-20')!);
|
||||
const text = root().textContent!.replace(/\s+/g, ' ');
|
||||
for (const value of [`Paciente ${row['id_seudonimo']}`, 'Fecha de corte: 2026-10-20', String(row['estatus']), String(row['prioridad']), String(row['birads']),
|
||||
String(row['mastografia_fecha']), String(row['biopsia']), String(row['biopsia_fecha']), String(row['dias_mastografia_diagnostico'])]) expect(text).toContain(value);
|
||||
});
|
||||
|
||||
// Fails if a missing value is left blank or invented instead of reading "No disponible".
|
||||
it('reads each missing value as "No disponible"', () => {
|
||||
montar(toCamaPatientSummary(incomplete(), '2026-10-20')!);
|
||||
const text = root().textContent!;
|
||||
expect(text).toContain('Resultado: No disponible');
|
||||
expect(text).toContain('Fecha de biopsia: No disponible');
|
||||
expect(text).toContain('Días de mastografía a diagnóstico');
|
||||
});
|
||||
|
||||
// Fails if a placeholder gains a figure or loses its explanation: no prognosis may be shown without a model.
|
||||
it('has placeholders, with no figures, for recurrence, survival and prognostic factors', () => {
|
||||
montar(toCamaPatientSummary(complete(), '2026-10-20')!);
|
||||
const items = [...root().querySelectorAll('[data-pronostico]')];
|
||||
expect(items.map(i => i.getAttribute('data-pronostico'))).toEqual(['recurrence', 'survival', 'factors']);
|
||||
expect(items.map(i => i.querySelector('strong')!.textContent)).toEqual(['Probabilidad de recurrencia', 'Supervivencia', 'Factores pronóstico']);
|
||||
for (const item of items) {
|
||||
expect(item.querySelector('span')!.textContent).toBe(PROGNOSIS_UNAVAILABLE);
|
||||
expect(item.textContent).not.toMatch(/\d/);
|
||||
}
|
||||
expect(root().textContent).toContain(RECOMMENDATIONS_UNAVAILABLE);
|
||||
});
|
||||
|
||||
// Fails if the record opens without moving focus to its title, which strands keyboard and screen-reader users.
|
||||
it('moves focus to its title when it opens', () => {
|
||||
montar(toCamaPatientSummary(complete(), '2026-10-20')!);
|
||||
expect(document.activeElement).toBe(root().querySelector('h2'));
|
||||
});
|
||||
|
||||
// Fails if the PDF button stops downloading, or the file name starts carrying the patient identifier.
|
||||
it('downloads the record as a PDF named without the patient', async () => {
|
||||
const downloads: string[] = [];
|
||||
vi.spyOn(URL, 'createObjectURL').mockImplementation(() => 'blob:test');
|
||||
vi.spyOn(URL, 'revokeObjectURL').mockImplementation(() => undefined);
|
||||
vi.spyOn(HTMLAnchorElement.prototype, 'click').mockImplementation(function (this: HTMLAnchorElement) { downloads.push(this.download); });
|
||||
const summary = toCamaPatientSummary(complete(), '2026-10-20')!;
|
||||
montar(summary);
|
||||
[...root().querySelectorAll('button')].find(b => b.textContent!.includes('Exportar ficha PDF'))!.click();
|
||||
for (let i = 0; i < 100 && !downloads.length; i++) await new Promise(r => setTimeout(r, 50));
|
||||
expect(downloads).toHaveLength(1);
|
||||
expect(downloads[0]).toMatch(/^ficha-cancer-de-mama_corte-2026-10-20_\d{8}-\d{4}\.pdf$/);
|
||||
expect(downloads[0]).not.toContain(summary.pseudonymId);
|
||||
vi.restoreAllMocks();
|
||||
}, 30000);
|
||||
|
||||
// Fails if the back button stops telling the list to return.
|
||||
it('emits back when "Regresar" is pressed', () => {
|
||||
montar(toCamaPatientSummary(complete(), '2026-10-20')!);
|
||||
let backs = 0;
|
||||
fixture.componentInstance.back.subscribe(() => backs++);
|
||||
[...root().querySelectorAll('button')].find(b => b.textContent!.includes('Regresar'))!.click();
|
||||
expect(backs).toBe(1);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,48 @@
|
||||
import { AfterViewInit, Component, ElementRef, input, output, signal, viewChild } from '@angular/core';
|
||||
import { downloadBlob, exportFilename } from '../../export/download-file';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { MatCardModule } from '@angular/material/card';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import {
|
||||
CamaPatientSummary, NOT_AVAILABLE, PROGNOSIS_PLACEHOLDERS, PROGNOSIS_UNAVAILABLE, RECOMMENDATIONS_UNAVAILABLE,
|
||||
} from './cama-patient.models';
|
||||
|
||||
/**
|
||||
* Individual record of a CaMa follow-up patient. It shows only what the follow-up list carries; recurrence,
|
||||
* survival and prognostic factors are placeholders until a validated model supplies them.
|
||||
*/
|
||||
@Component({
|
||||
selector: 'app-cama-patient-card',
|
||||
imports: [MatButtonModule, MatCardModule, MatIconModule],
|
||||
templateUrl: './cama-patient-card.html',
|
||||
styleUrl: './cama-patient-card.scss',
|
||||
})
|
||||
export class CamaPatientCard implements AfterViewInit {
|
||||
readonly summary = input.required<CamaPatientSummary>();
|
||||
readonly back = output<void>();
|
||||
readonly notAvailable = NOT_AVAILABLE;
|
||||
readonly placeholders = PROGNOSIS_PLACEHOLDERS;
|
||||
readonly prognosisUnavailable = PROGNOSIS_UNAVAILABLE;
|
||||
readonly recommendationsUnavailable = RECOMMENDATIONS_UNAVAILABLE;
|
||||
private readonly title = viewChild<ElementRef<HTMLElement>>('title');
|
||||
readonly generating = signal(false);
|
||||
readonly failed = signal(false);
|
||||
|
||||
ngAfterViewInit() { this.title()?.nativeElement.focus(); }
|
||||
|
||||
/** Downloads the record as a PDF. The file name carries the report and the cut-off, never the patient. */
|
||||
async exportPdf() {
|
||||
if (this.generating()) return;
|
||||
this.generating.set(true); this.failed.set(false);
|
||||
try {
|
||||
const patient = this.summary();
|
||||
// The PDF library downloads only when the button is used.
|
||||
const blob = await (await import('./cama-patient-pdf')).buildCamaPatientPdf(patient);
|
||||
downloadBlob(blob, exportFilename('ficha-cancer-de-mama', patient.cutoff, 'pdf'));
|
||||
} catch {
|
||||
this.failed.set(true);
|
||||
} finally {
|
||||
this.generating.set(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
// Covers the one-patient PDF: that it reuses the institutional frame of the follow-up report in portrait, prints only
|
||||
// the fields of the record, shows placeholders (no figures) for recurrence, survival and prognostic factors, and
|
||||
// renders to a real PDF file. Fixture: fixtures/cama_seguimiento.json. The logo is left out of the render test
|
||||
// because the test browser has no `Worker` to decode a PNG; the image path is checked in a real browser.
|
||||
import fixtureData from '../../fixtures/cama_seguimiento.json';
|
||||
import { seguimientoTablaResponse } from '../../seguimiento-tabla.service';
|
||||
import { PDF_CONFIDENTIAL } from '../../export/pdf-template';
|
||||
import { buildCamaPatientPdf, camaPatientDocument, PATIENT_TITLE } from './cama-patient-pdf';
|
||||
import { PROGNOSIS_UNAVAILABLE, RECOMMENDATIONS_UNAVAILABLE, toCamaPatientSummary } from './cama-patient.models';
|
||||
|
||||
const NOW = new Date(Date.UTC(2026, 10, 12, 21, 30));
|
||||
const rows = () => seguimientoTablaResponse(structuredClone(fixtureData)).items;
|
||||
const complete = () => toCamaPatientSummary(rows().find(r => r['biopsia'] !== null && r['dias_mastografia_diagnostico'] !== null)!, '2026-10-20')!;
|
||||
const incomplete = () => toCamaPatientSummary(rows().find(r => r['biopsia'] === null)!, '2026-10-20')!;
|
||||
const definition = (p = complete(), logo?: string) => camaPatientDocument(p, NOW, logo) as Record<string, any>;
|
||||
function texts(node: unknown, out: string[] = []): string[] {
|
||||
if (typeof node === 'string') out.push(node);
|
||||
else if (Array.isArray(node)) node.forEach(n => texts(n, out));
|
||||
else if (node && typeof node === 'object') Object.values(node).forEach(n => texts(n, out));
|
||||
return out;
|
||||
}
|
||||
|
||||
describe('Ficha CaMa: PDF individual', () => {
|
||||
// Fails if the record stops sharing the report's frame (header, footer, properties) or leaves portrait.
|
||||
it('uses the institutional frame in portrait, with the title in the header and the confidentiality line in the footer', () => {
|
||||
const d = definition(complete(), 'data:image/png;base64,AAAA');
|
||||
expect(d['pageOrientation']).toBe('portrait');
|
||||
expect(d['info']).toMatchObject({ title: PATIENT_TITLE, author: 'ISSSTELEON' });
|
||||
expect(texts(d['header']())).toEqual(expect.arrayContaining([PATIENT_TITLE]));
|
||||
expect(JSON.stringify(d['header']())).toContain('"image":"logo"');
|
||||
expect(texts(d['footer'](1, 1))).toEqual(expect.arrayContaining(['Página 1 de 1', PDF_CONFIDENTIAL]));
|
||||
});
|
||||
|
||||
// Fails if a field of the record is left out of the document or printed under another label.
|
||||
it('prints each field of the record under its label', () => {
|
||||
const p = complete();
|
||||
const found = texts(definition(p)['content']);
|
||||
for (const t of [`Paciente ${p.pseudonymId}`, 'Fecha de corte: 2026-10-20', p.status!, p.priority!, p.birads!, p.mammographyDate!, p.histopathology!, p.biopsyDate!, String(p.daysMammographyToDiagnosis),
|
||||
'Categoría BI-RADS', 'Fecha de la mastografía', 'Resultado histopatológico', 'Fecha de biopsia', 'Días de mastografía a diagnóstico']) expect(found).toContain(t);
|
||||
});
|
||||
|
||||
// Fails if a missing value is printed as something other than "No disponible".
|
||||
it('prints a missing value as "No disponible"', () => {
|
||||
const found = texts(definition(incomplete())['content']);
|
||||
expect(found.filter(t => t === 'No disponible').length).toBeGreaterThanOrEqual(2);
|
||||
});
|
||||
|
||||
// Fails if a placeholder gains a figure or an explanation other than "unavailable".
|
||||
it('has placeholders, with no figures, for recurrence, survival, prognostic factors and recommendations', () => {
|
||||
const found = texts(definition()['content']);
|
||||
for (const t of ['Probabilidad de recurrencia', 'Supervivencia', 'Factores pronóstico', PROGNOSIS_UNAVAILABLE, RECOMMENDATIONS_UNAVAILABLE]) expect(found).toContain(t);
|
||||
expect(found.filter(t => t === PROGNOSIS_UNAVAILABLE)).toHaveLength(3);
|
||||
});
|
||||
|
||||
// Fails if the document carries a platform identifier field.
|
||||
it('contains no platform identifier', () => {
|
||||
const p = complete();
|
||||
expect(texts(definition(p)['info'])).not.toContain('pac_id');
|
||||
});
|
||||
|
||||
// Fails if the document no longer renders to a real PDF file.
|
||||
it('renders a PDF file', async () => {
|
||||
const blob = await buildCamaPatientPdf(complete(), NOW);
|
||||
const bytes = new TextDecoder('latin1').decode(new Uint8Array(await blob.arrayBuffer()));
|
||||
expect(bytes.startsWith('%PDF-')).toBe(true);
|
||||
expect(bytes.trimEnd().endsWith('%%EOF')).toBe(true);
|
||||
expect((bytes.match(/\/Type \/Page\b/g) ?? []).length).toBe(1);
|
||||
}, 30000);
|
||||
});
|
||||
@@ -0,0 +1,41 @@
|
||||
import { renderPdf, PdfDefinition } from '../../export/pdf-engine';
|
||||
import { COLORS, institutionalDocument, loadLogo } from '../../export/pdf-template';
|
||||
import {
|
||||
CamaPatientSummary, NOT_AVAILABLE, PROGNOSIS_PLACEHOLDERS, PROGNOSIS_UNAVAILABLE, RECOMMENDATIONS_UNAVAILABLE,
|
||||
} from './cama-patient.models';
|
||||
|
||||
export const PATIENT_TITLE = 'Ficha de paciente — Cáncer de mama';
|
||||
|
||||
const rule = { hLineWidth: () => 0.5, vLineWidth: () => 0, hLineColor: () => COLORS.rule, paddingTop: () => 4, paddingBottom: () => 4 };
|
||||
const value = (v: string | number | null) => (v === null ? { text: NOT_AVAILABLE, italics: true, color: COLORS.muted } : { text: String(v) });
|
||||
const section = (title: string, rows: [string, string | number | null][]) => [
|
||||
{ text: title, style: 'h2' },
|
||||
{ table: { widths: [170, '*'], body: rows.map(([label, v]) => [{ text: label, bold: true }, value(v)]) }, layout: rule },
|
||||
];
|
||||
|
||||
/** The document definition of one patient's record. Exported so its content can be checked without rendering. */
|
||||
export function camaPatientDocument(patient: CamaPatientSummary, now: Date, logo?: string): PdfDefinition {
|
||||
return institutionalDocument({ title: PATIENT_TITLE, logo, now, orientation: 'portrait' }, [
|
||||
{ text: `Paciente ${patient.pseudonymId}`, style: 'h1' },
|
||||
{ text: `Fecha de corte: ${patient.cutoff}`, style: 'muted' },
|
||||
...section('Resumen', [
|
||||
['Identificador seudónimo', patient.pseudonymId],
|
||||
['Grupo de edad', patient.ageGroup],
|
||||
['Estatus de seguimiento', patient.status],
|
||||
['Prioridad', patient.priority],
|
||||
['Días de mastografía a diagnóstico', patient.daysMammographyToDiagnosis],
|
||||
]),
|
||||
...section('Mastografía', [['Categoría BI-RADS', patient.birads], ['Fecha de la mastografía', patient.mammographyDate]]),
|
||||
...section('Histopatología', [['Resultado histopatológico', patient.histopathology], ['Fecha de biopsia', patient.biopsyDate]]),
|
||||
...section('Pronóstico y recomendaciones', [
|
||||
...PROGNOSIS_PLACEHOLDERS.map(p => [p.label, PROGNOSIS_UNAVAILABLE] as [string, string]),
|
||||
['Recomendaciones', RECOMMENDATIONS_UNAVAILABLE],
|
||||
]),
|
||||
{ text: '“No disponible” indica dato no registrado, no ausencia clínica.', style: 'small', margin: [0, 10, 0, 0] },
|
||||
]);
|
||||
}
|
||||
|
||||
/** A one-patient PDF with the same frame as the follow-up report. */
|
||||
export async function buildCamaPatientPdf(patient: CamaPatientSummary, now = new Date(), logo?: string): Promise<Blob> {
|
||||
return renderPdf(camaPatientDocument(patient, now, logo ?? await loadLogo()));
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
import { TrackingRow } from '../../export/tracking-export.models';
|
||||
|
||||
export const NOT_AVAILABLE = 'No disponible';
|
||||
|
||||
/**
|
||||
* What the CaMa follow-up list says about one patient, read from the row that was clicked. `pseudonymId` is the
|
||||
* synthetic `M-…` identifier of the list; it is not a platform identifier and is never sent anywhere.
|
||||
*/
|
||||
export interface CamaPatientSummary {
|
||||
pseudonymId: string;
|
||||
cutoff: string;
|
||||
ageGroup: string | null;
|
||||
status: string | null;
|
||||
priority: string | null;
|
||||
birads: string | null;
|
||||
mammographyDate: string | null;
|
||||
histopathology: string | null;
|
||||
biopsyDate: string | null;
|
||||
daysMammographyToDiagnosis: number | null;
|
||||
}
|
||||
|
||||
/** Placeholders for results that exist only once a validated model and its clinical definition do. */
|
||||
export const PROGNOSIS_PLACEHOLDERS = [
|
||||
{ key: 'recurrence', label: 'Probabilidad de recurrencia' },
|
||||
{ key: 'survival', label: 'Supervivencia' },
|
||||
{ key: 'factors', label: 'Factores pronóstico' },
|
||||
] as const;
|
||||
export const PROGNOSIS_UNAVAILABLE = 'No disponible: pendiente de definición clínica y de un modelo validado.';
|
||||
export const RECOMMENDATIONS_UNAVAILABLE = 'Recomendaciones no disponibles.';
|
||||
|
||||
const text = (v: unknown) => (typeof v === 'string' && v.length > 0 ? v : null);
|
||||
|
||||
/** The patient summary of a follow-up row, or `null` when the row has no identifier to show. */
|
||||
export function toCamaPatientSummary(row: TrackingRow, cutoff: string): CamaPatientSummary | null {
|
||||
const pseudonymId = text(row['id_seudonimo']);
|
||||
if (!pseudonymId) return null;
|
||||
const days = row['dias_mastografia_diagnostico'];
|
||||
return {
|
||||
pseudonymId,
|
||||
cutoff,
|
||||
ageGroup: text(row['grupo_edad']),
|
||||
status: text(row['estatus']),
|
||||
priority: text(row['prioridad']),
|
||||
birads: text(row['birads']),
|
||||
mammographyDate: text(row['mastografia_fecha']),
|
||||
histopathology: text(row['biopsia']),
|
||||
biopsyDate: text(row['biopsia_fecha']),
|
||||
daysMammographyToDiagnosis: typeof days === 'number' && Number.isFinite(days) ? days : null,
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user