# domain/converters/document.converter.ts

> 47 lines of code and 4 definitions.

Tree: Site tree
Language: typescript
Layer: processing
Canonical: https://banes-lab.com/anatomy/tree#file-domain-converters-document-converter-ts
Source text: https://banes-lab.com/assets/sources/source.80b1141146085fcb7b9a27f8d6034985c6ed8b75f8438d8e5b7f90e468ed5c97.generated.txt

## Definitions

- `documentBlocks` (lexical_declaration, line 31, exported)
- `documentChips` (lexical_declaration, line 20, exported)
- `metrics` (lexical_declaration, line 32, exported)
- `rows` (lexical_declaration, line 39, exported)

## Uses

- [domain/converters/ontology.converter.ts](https://banes-lab.com/source/tree/domain/converters/ontology.converter.ts.md)

## Used by

- [domain/converters/anatomy.converter.ts](https://banes-lab.com/source/tree/domain/converters/anatomy.converter.ts.md)

## Source

```typescript
import {
    BOUNDARY_LABEL,
    CONCERN_LABEL,
    CONSTRUCTS_LABEL,
    DOCUMENT_FINDINGS_LABEL,
    DOCUMENT_LABEL,
    FIELDS_LABEL,
    FORM_LABEL,
    HEADINGS_LABEL,
    LINE_MARK,
    MERMAID_LABEL,
    PATHS_LABEL,
} from "#configuration/strings/folder.strings";
import { glossary, labelled, row } from "#domain/converters/ontology.converter";
import type { Block } from "#types/block.types";
import type { DocumentView } from "#types/anatomy.types";
import { NONE_LABEL } from "#configuration/strings/ontology.strings";
import { STATS_SEPARATOR } from "#configuration/constants/anatomy.constants";

export const documentChips = function documentChips(document: DocumentView | null): (string | null)[] {
    if (document === null) {
        return [];
    }
    return [
        labelled(FORM_LABEL, document.form),
        labelled(CONCERN_LABEL, document.concern),
        document.boundary ? BOUNDARY_LABEL : null,
    ];
};

export const documentBlocks = function documentBlocks(document: DocumentView): Block[] {
    const metrics = [
        { label: HEADINGS_LABEL, value: String(document.headings) },
        { label: MERMAID_LABEL, value: String(document.mermaid) },
        { label: PATHS_LABEL, value: String(document.paths) },
        { label: CONSTRUCTS_LABEL, value: String(document.constructs) },
        { label: FIELDS_LABEL, value: String(document.fields.length) },
    ];
    const rows = document.findings.map((finding) =>
        row(
            finding.code + LINE_MARK + String(finding.line),
            `<strong>${finding.category}</strong>${STATS_SEPARATOR}${finding.text}`,
        ),
    );
    return [
        { caption: DOCUMENT_LABEL, kind: "metric" as const, metrics },
        glossary(rows.length === 0 ? [row(DOCUMENT_FINDINGS_LABEL, NONE_LABEL)] : rows),
    ];
};
```
