feat(cama): readable BI-RADS and age labels, the biopsy report date, and no export of a list that does not match its group
Contract review against WebApi 1d5f1e0 (webapi/cama_analysis.py, cama_cohort.py, docs/cama-cohort-api.md).
- The cohort's list is rewritten once on arrival so the table, the record and the PDF/XLSX show
"BI-RADS 5" and "50 a 59 años" (also "Menores de 40 años", "70 años o más", "Sin dato"); the codes
stay in `<clave>_codigo` and in the filter options, which are what the requests send. Only codes
whose meaning the API's own code confirms are labelled; biopsy grades are left as they arrive.
- The record calls the biopsy date what the list calls it ("Fecha de reporte"): in the cohort it is
the date of the biopsy report, which can be known while its result is not.
- With the same cohort revision, cut-off and filter the aggregate and the list are counted from the
same rows, so a different total breaks the contract: the list shows an alert and its PDF/XLSX
buttons are disabled.
- When no category is published the analysis says so and keeps "No publicado": the answer cannot
tell an empty cohort from categories under the threshold.
- Tests: the chosen cut-off reaches the aggregate, the list, the record and every page of the file.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -29,7 +29,7 @@
|
||||
<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>
|
||||
<li><strong>Resultado histopatológico</strong><span>Resultado: {{ p.histopathology ?? notAvailable }}</span><span>{{ p.biopsyDateLabel ?? 'Fecha de biopsia' }}: {{ p.biopsyDate ?? notAvailable }}</span></li>
|
||||
</ul>
|
||||
</mat-card-content>
|
||||
</mat-card>
|
||||
|
||||
@@ -26,7 +26,7 @@ export function camaPatientDocument(patient: CamaPatientSummary, now: Date, logo
|
||||
['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('Histopatología', [['Resultado histopatológico', patient.histopathology], [patient.biopsyDateLabel ?? 'Fecha de biopsia', patient.biopsyDate]]),
|
||||
...section('Pronóstico y recomendaciones', [
|
||||
...PROGNOSIS_PLACEHOLDERS.map(p => [p.label, PROGNOSIS_UNAVAILABLE] as [string, string]),
|
||||
['Recomendaciones', RECOMMENDATIONS_UNAVAILABLE],
|
||||
|
||||
@@ -16,6 +16,8 @@ export interface CamaPatientSummary {
|
||||
mammographyDate: string | null;
|
||||
histopathology: string | null;
|
||||
biopsyDate: string | null;
|
||||
/** What the list calls that date: the cohort's list gives the date of the biopsy report, which can be known before its result is. */
|
||||
biopsyDateLabel?: string;
|
||||
daysMammographyToDiagnosis: number | null;
|
||||
}
|
||||
|
||||
@@ -30,10 +32,14 @@ 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 {
|
||||
/**
|
||||
* The patient summary of a follow-up row, or `null` when the row has no identifier to show. `columnas` are the ones the
|
||||
* list announced: the label it gives to the biopsy date is kept, so the record says the same as the list.
|
||||
*/
|
||||
export function toCamaPatientSummary(row: TrackingRow, cutoff: string, columnas: readonly { clave: string; detalles?: readonly { clave: string; etiqueta: string }[] }[] = []): CamaPatientSummary | null {
|
||||
const pseudonymId = text(row['id_seudonimo']);
|
||||
if (!pseudonymId) return null;
|
||||
const etiquetaFecha = columnas.flatMap(c => c.detalles ?? []).find(d => d.clave === 'biopsia_fecha')?.etiqueta;
|
||||
const days = row['dias_mastografia_diagnostico'];
|
||||
return {
|
||||
pseudonymId,
|
||||
@@ -45,6 +51,7 @@ export function toCamaPatientSummary(row: TrackingRow, cutoff: string): CamaPati
|
||||
mammographyDate: text(row['mastografia_fecha']),
|
||||
histopathology: text(row['biopsia']),
|
||||
biopsyDate: text(row['biopsia_fecha']),
|
||||
...(etiquetaFecha ? { biopsyDateLabel: etiquetaFecha } : {}),
|
||||
daysMammographyToDiagnosis: typeof days === 'number' && Number.isFinite(days) ? days : null,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user