import type { TFunction } from 'i18next'; import { type PracticeAnamnesisConfig } from './anamnesis-config'; import { type DisclosureAudience } from './anamnesis-disclosure'; import type { AnamnesisRecord, NumericParameterDef } from './anamnesis-types'; /** A cell. `null` is ABSENT and every writer renders it as an empty cell — * never the em dash the screen uses, which a spreadsheet cannot compute on. */ export type ExportValue = string | number | null; export interface ExportColumn { /** Stable key — the Excel column key, never rendered. */ key: string; /** Translated header text. */ header: string; /** Numbers land in this column: right-aligned and number-formatted. */ numeric?: boolean; /** Decimal places for numeric cells, when the whole column shares one. */ precision?: number; } export interface ExportRow { /** `section` is a group banner: cell 0 carries the label, the rest is blank. */ kind?: 'data' | 'section'; /** Aligned to `columns` by index; short rows are padded by the writer. */ cells: ExportValue[]; /** Decimal places for THIS row's numeric cells — a parameter row carries its * own precision, and the column cannot know it. Wins over the column. */ precision?: number; } export interface ExportTable { /** Stable id — the worksheet key and the PDF anchor. */ id: string; title: string; columns: ExportColumn[]; rows: ExportRow[]; /** Rendered in place of the rows when there are none. */ emptyText?: string; } export interface ExportMetaEntry { label: string; value: string; } /** Which tab was exported. */ export type AnamnesisExportTab = 'summary' | 'compile' | 'evolution'; export interface ExportDocument { tab: AnamnesisExportTab; audience: DisclosureAudience; /** Filename without an extension — see `exportFileName`. */ fileStem: string; title: string; /** Who the copy names, or `null` when identity is not disclosed to this * audience. Lifted out of `meta` so a writer can stamp every page with it. */ patientName: string | null; /** The audience, translated — the "Copy for" value, in one place. */ audienceLabel: string; meta: ExportMetaEntry[]; tables: ExportTable[]; /** Translated notes rendered under the tables. */ footnotes: string[]; /** Disclosure concept IDS held back from this document. Metadata for the UI * and the tests — writers never print it, because an id is not a value. */ withheld: string[]; /** App locale, resolved from `t`. Drives the CSV dialect. */ locale?: string; } export interface AnamnesisExportOptions { record: AnamnesisRecord; /** Who the file is for. Filters every table through `disclosedTo`. */ audience: DisclosureAudience; t: TFunction; config?: PracticeAnamnesisConfig; /** Generation instant. Defaults to now — pass one to keep a test stable. */ generatedAtIso?: string; } /** `selected` exports the columns the picker is showing; `all` exports every * visit. Defaults to `selected`: exporting thirteen visits from a screen * showing three is a different document from the one that was asked for. */ export type EvolutionExportScope = 'selected' | 'all'; export interface EvolutionExportOptions extends AnamnesisExportOptions { /** The picker's current selection. Omitted = the picker's own default * (first visit + latest), never "everything". */ selectedVisitIds?: Iterable; scope?: EvolutionExportScope; } /** A parameter's disclosure concept, from its DISPLAY group — not from * `parameterStorage`, which routes a practice-added anthropometric through the * `labs` array and would classify it as a lab value. */ export declare function parameterConcept(def: NumericParameterDef): string; /** The Summary tab: the patient's own questionnaire, one row per answered * question, grouped by section, with who authored each answer. */ export declare function buildSummaryExport(options: AnamnesisExportOptions): ExportDocument; /** The Compile tab: the visit being recorded, block by block, in the order the * form presents them. Each block is gated on its own disclosure concept. */ export declare function buildCompileExport(options: AnamnesisExportOptions): ExportDocument; /** The Evolution tab: parameters as rows, the SHOWN visits as columns, plus * target, window change and which visits fell out of range. */ export declare function buildEvolutionExport(options: EvolutionExportOptions): ExportDocument; /** One entry point for a tab id — the UI stage switches on the active tab. */ export declare function buildAnamnesisExport(tab: AnamnesisExportTab, options: EvolutionExportOptions): ExportDocument; /** A withheld concept's translated name. The id carries dots and i18next reads * a dot as a level, so the key flattens them — `lab.values` reads * `anamnesis.export.concept.lab_values`. An id with no key falls back to the * id rather than to a blank, so a rule nobody has named still shows up. */ export declare function conceptLabel(conceptId: string, t: TFunction): string; export interface DocumentDisclosure { /** Table titles the document actually carries, in document order. */ included: string[]; /** Translated names of the concepts held back, alphabetical. */ excluded: string[]; } /** What this document gives the audience and what it holds back — the share * dialog's whole content, and the menu's exclusion line. Reads the built * document rather than re-deriving the rules, so the preview cannot disagree * with the file. */ export declare function documentDisclosure(document: ExportDocument, t: TFunction): DocumentDisclosure; export declare const CSV_MIME = "text/csv;charset=utf-8"; export declare const XLSX_MIME = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; export interface CsvDialect { /** Field separator. `;` wherever the decimal mark is a comma. */ delimiter: ',' | ';'; decimal: '.' | ','; eol: string; /** Emit a UTF-8 BOM so Excel detects the encoding instead of guessing. */ bom: boolean; } /** The CSV convention Excel expects for a locale. Italian (and every other * decimal-comma locale) gets `;` + `,`; English gets `,` + `.`. A locale whose * decimal mark is neither — Arabic's `٫` — takes the point convention, because * the numbers written here are Latin digits either way. */ export declare function csvDialectFor(locale?: string): CsvDialect; /** One cell, escaped. Exported for the tests that pin the escaping rules. */ export declare function csvCell(value: ExportValue, dialect: CsvDialect, precision?: number): string; /** The document as one CSV. Tables run in order, each behind its own title * row and separated by a blank line — the report shape every spreadsheet * reader already understands. */ export declare function toCsv(document: ExportDocument, dialect?: CsvDialect): string; export declare function toCsvBlob(document: ExportDocument, dialect?: CsvDialect): Blob; /** The document as an `.xlsx` — the info block on its own sheet, then one * sheet per table. No colour: the kit's tokens are CSS custom properties that * only resolve against a live DOM, and this module has none. Weight and * freeze-panes carry the hierarchy instead. The workbook library is * dynamic-imported so it stays out of the bundle of a consumer who never * exports. */ export declare function toXlsxBlob(document: ExportDocument): Promise; export type ExportFormat = 'csv' | 'xlsx' | 'pdf'; /** Deterministic, meaningful, and free of anything a filesystem rejects. */ export declare function exportFileName(document: ExportDocument, format: ExportFormat): string; //# sourceMappingURL=anamnesis-export.d.ts.map