56 lines
1.5 KiB
TypeScript
56 lines
1.5 KiB
TypeScript
import type { Sheet } from '../export';
|
|
import type { RiskScale } from './risk-scales';
|
|
import { Stage, STATES } from './stages';
|
|
const NONE = 'No disponible';
|
|
const percent = (p: number) => `${(100 * p).toFixed(2)} %`;
|
|
interface Event {
|
|
date: string;
|
|
kind: string;
|
|
text: string;
|
|
}
|
|
interface Test {
|
|
date: string;
|
|
kind: string;
|
|
reported?: string;
|
|
results: string[];
|
|
}
|
|
export function recordSheets(
|
|
facts: [string, string | undefined][],
|
|
stages: Stage[],
|
|
history: Event[],
|
|
tests: Test[],
|
|
scales: RiskScale[],
|
|
): Sheet[] {
|
|
return [
|
|
{
|
|
title: 'Datos de la paciente',
|
|
head: ['Dato', 'Valor'],
|
|
rows: facts.map(([k, v]) => [k, v || NONE]),
|
|
},
|
|
{
|
|
title: 'Etapas del tamizaje',
|
|
head: ['Etapa', 'Estado', 'Fecha'],
|
|
rows: stages.map((s) => [s.label, STATES[s.state], s.day ?? '']),
|
|
},
|
|
{
|
|
title: 'Historial médico',
|
|
head: ['Fecha', 'Tipo', 'Detalle'],
|
|
rows: history.map((h) => [h.date, h.kind, h.text]),
|
|
},
|
|
{
|
|
title: 'Pruebas y resultados',
|
|
head: ['Toma', 'Estudio', 'Reporte', 'Resultados'],
|
|
rows: tests.map((t) => [t.date, t.kind, t.reported ?? 'Pendiente', t.results.join(' · ')]),
|
|
},
|
|
{
|
|
title: 'Riesgos',
|
|
head: ['Riesgo', 'Probabilidad', 'IC 95 %'],
|
|
rows: scales.map(({ label, risk }) => [
|
|
label,
|
|
risk ? percent(risk.p) : NONE,
|
|
risk?.low === undefined ? NONE : `${percent(risk.low)} a ${percent(risk.high!)}`,
|
|
]),
|
|
},
|
|
];
|
|
}
|