# VFS Paths

URL: https://docs.clinia.com/api/vfs-paths

> Complete reference for all Virtual File System path patterns, file types, and entry naming rules.

The Virtual File System (VFS) exposes the resolved patient graph as a navigable directory tree. All paths are relative to the patient root. Content is materialized lazily from the live graph on each request. Nothing is stored as pre-rendered files.

## Entity types [#entity-types]

Each entity in the resolved graph has a `type` that determines which VFS category it lives in. Internal infrastructure types (`device`) are used by the pipeline but are not exposed through the VFS.

| Type             | VFS path                 | Description                                |
| ---------------- | ------------------------ | ------------------------------------------ |
| `condition`      | `/conditions/{status}/`  | Diagnoses, problems, and clinical findings |
| `medication`     | `/medications/{status}/` | Drugs, dosages, and administration records |
| `lab`            | `/labs/`                 | Laboratory observations and results        |
| `allergy`        | `/allergies/`            | Allergy and intolerance records            |
| `encounter`      | `/encounters/{year}/`    | Clinical encounters, organized by year     |
| `family_history` | `/family_history/`       | Conditions recorded as family history      |
| `social_history` | `/social_history/`       | Lifestyle, behavior, and context facts     |
| `insurance`      | `/insurance/`            | Coverage and payer information             |
| `directive`      | `/directives/`           | Advance directives and consent records     |

Two VFS categories are not entity-backed and so do not appear above: `/memory/`, which holds conversation-derived memories, and `/sources/`, which holds the documents the record was assembled from. Both are covered under [Path reference](#path-reference).

## Statuses [#statuses]

Conditions and medications carry a `status` field that names the subdirectory they appear in.

| Applies to  | Statuses                                                    | VFS subdirectory         |
| ----------- | ----------------------------------------------------------- | ------------------------ |
| conditions  | `active`, `resolved`, `inactive`, `unknown`                 | `/conditions/{status}/`  |
| medications | `active`, `on-hold`, `completed`, `discontinued`, `unknown` | `/medications/{status}/` |

A status with nothing in it is still listed, with a count of zero.

Conditions coded as family history (Z80–Z84, or a display naming a relative) are reclassified and appear under `/family_history/` regardless of how they were originally coded.

## Entry names [#entry-names]

An entry that stands for one item of the record is named by that item's id. The id's prefix tells what the item is:

| Prefix | Item                                                                                 |
| ------ | ------------------------------------------------------------------------------------ |
| `fct_` | A condition, medication, allergy, directive, coverage, family or social history fact |
| `ece_` | An encounter or another dated event                                                  |
| `nar_` | A narrative                                                                          |
| `en_`  | A source document                                                                    |

Each such entry carries a `display` field with its readable name, for example `"Type 2 diabetes mellitus"`. Choose an entry by its `display`, then read it by its `name`.

A medication's `display` names its ingredients and route, such as `acetaminophen / codeine phosphate, oral`, when the engine knows both. Otherwise it keeps the name the record gave it.

A lab trend is named after its test, as [Labs](#labs) describes.

## Path reference [#path-reference]

### Root [#root]

| Path | Type      | Returns                        |
| ---- | --------- | ------------------------------ |
| `/`  | directory | Every category, with its count |

A category with nothing in it is still listed, with a count of zero. The same holds at every level: an empty directory, such as a status with no conditions, is listed with its zero count.

### Conditions [#conditions]

| Path                                                  | Type      | Returns                                                         |
| ----------------------------------------------------- | --------- | --------------------------------------------------------------- |
| `/conditions/`                                        | directory | One subdirectory per status                                     |
| `/conditions/{status}/`                               | directory | The conditions with that status, with status previews           |
| `/conditions/{status}/{id}/`                          | directory | `_story.md` and `_narratives/` for this condition               |
| `/conditions/{status}/{id}/_story.md`                 | file      | Full longitudinal condition narrative                           |
| `/conditions/{status}/{id}/_narratives/`              | directory | Narratives a verification verdict links to this condition       |
| `/conditions/{status}/{id}/_narratives/{narrativeId}` | file      | One narrative and every verdict it holds against this condition |

`{status}` is one of `active`, `resolved`, `inactive` or `unknown`.

`_narratives/` is always listed, reporting `0 narratives` when nothing links to the
condition.

A narrative leaf is the narrative's title followed by one section per verdict — worst
first — carrying the reasoning behind that verdict against this condition. `structured`
returns the same fields as JSON, with the model that produced the reasoning; `compact`
returns its title and every verdict kind, worst first, on one line.

No part of a leaf is verbatim note text. For the wording a clinician recorded, read the
document itself under [`/sources/`](#sources) — the leaf does not name which one, so find it
with [`search_patient`](https://docs.clinia.com/api/mcp/tools/search-patient).

Read `_story.md` with `format=structured` to get the condition's fields and the story's
related records as JSON.

### Medications [#medications]

| Path                         | Type      | Returns                                                          |
| ---------------------------- | --------- | ---------------------------------------------------------------- |
| `/medications/`              | directory | One subdirectory per status                                      |
| `/medications/{status}/`     | directory | The medications with that status                                 |
| `/medications/{status}/{id}` | file      | Medication detail: name, dosage, prescriber, period, RxNorm code |

`{status}` is one of `active`, `on-hold`, `completed`, `discontinued` or `unknown`. Medications are leaf files. They do not have `_story.md` or any other sub-path.

One medication file can gather several records of the same drug. The `narrative` format ends with a `## Doses and frequencies` section listing the dose and frequency of each record, records that agree sharing one line, most recent first, with when it was mentioned, its status, and the records it came from. The `structured` format carries the same list as a `variants` array.

### Labs [#labs]

| Path                  | Type      | Returns                                              |
| --------------------- | --------- | ---------------------------------------------------- |
| `/labs/`              | directory | `latest` entry and `trends/` subdirectory            |
| `/labs/latest`        | file      | Most recent value of every test, sorted by test name |
| `/labs/trends/`       | directory | One entry per test with recorded lab history         |
| `/labs/trends/{test}` | file      | Full chronological time series for a single test     |

`{test}` names the test in one of these ways:

- by its LOINC code, such as `4548-4`;
- by its name and its local code, such as `potassium-CHEM~2FK` for `CHEM/K`;
- by its name alone, such as `poc_glucose`.

Take the name from the `/labs/trends/` listing.

### Allergies [#allergies]

| Path              | Type      | Returns                                              |
| ----------------- | --------- | ---------------------------------------------------- |
| `/allergies/`     | directory | All allergies                                        |
| `/allergies/{id}` | file      | Allergy detail: substance, reaction, severity, onset |

### Directives [#directives]

| Path               | Type      | Returns                                                        |
| ------------------ | --------- | -------------------------------------------------------------- |
| `/directives/`     | directory | All advance directives                                         |
| `/directives/{id}` | file      | Directive detail: type, status, effective date, document title |

### Encounters [#encounters]

Encounters are organized by year. Only an encounter that addressed a condition is listed. Browse [`/timeline/`](#timeline) to find every visit.

| Path                      | Type      | Returns                                                                      |
| ------------------------- | --------- | ---------------------------------------------------------------------------- |
| `/encounters/`            | directory | Year subdirectories that contain at least one encounter                      |
| `/encounters/{year}/`     | directory | Encounter files for that year                                                |
| `/encounters/{year}/{id}` | file      | Encounter detail: date, class, provider, reason, the conditions it addressed |

### Insurance [#insurance]

| Path              | Type      | Returns                                                                      |
| ----------------- | --------- | ---------------------------------------------------------------------------- |
| `/insurance/`     | directory | All insurance coverages                                                      |
| `/insurance/{id}` | file      | Coverage detail: payer, plan name, member ID, group number, effective period |

### Family history [#family-history]

| Path                   | Type      | Returns                                                       |
| ---------------------- | --------- | ------------------------------------------------------------- |
| `/family_history/`     | directory | All family history entries                                    |
| `/family_history/{id}` | file      | Family history detail: condition, relation, onset if recorded |

### Social history [#social-history]

| Path                   | Type      | Returns                                            |
| ---------------------- | --------- | -------------------------------------------------- |
| `/social_history/`     | directory | All social history entries                         |
| `/social_history/{id}` | file      | Social history detail: category, value, and source |

### Timeline [#timeline]

| Path                    | Type      | Returns                                              |
| ----------------------- | --------- | ---------------------------------------------------- |
| `/timeline/`            | directory | Year subdirectories that contain events              |
| `/timeline/{year}/`     | directory | The events of that year                              |
| `/timeline/{year}/{id}` | file      | Single event detail: type, date, description, source |

Events include encounters, procedures, lab draws, and immunization administrations. Each occurrence is preserved as a distinct timeline entry. Events are not deduplicated.

### Memory [#memory]

| Path                    | Type      | Returns                                                             |
| ----------------------- | --------- | ------------------------------------------------------------------- |
| `/memory/`              | directory | One file per memory type with a count preview                       |
| `/memory/symptom.md`    | file      | All reported clinical statements, most recent first                 |
| `/memory/adherence.md`  | file      | All medication-taking behavior statements, most recent first        |
| `/memory/concern.md`    | file      | All worries and open questions about the patient, most recent first |
| `/memory/preference.md` | file      | All care and communication preferences, most recent first           |

Each file is a Markdown list. Every entry includes the verbatim statement, the date it was recorded, and the session it came from. Memories are added as each ingestion of a session's turns is processed. See [How Interactions Become Memory](https://docs.clinia.com/docs/learned-memory/overview).

### Sources [#sources]

| Path                                  | Type      | Returns                                                |
| ------------------------------------- | --------- | ------------------------------------------------------ |
| `/sources/`                           | directory | One entry per document title, largest group first      |
| `/sources/{title}/`                   | directory | Documents sharing that title, newest first             |
| `/sources/{title}/{doc}/`             | directory | One entry per section of that document, largest first  |
| `/sources/{title}/{doc}`              | file      | Every section of the document, in order, with a header |
| `/sources/{title}/{doc}/{section}.md` | file      | A single section                                       |

Every other category answers a clinical question. This one is a raw view of the inputs: what a named document says, as ingested. Use it when the question is phrased against a document — what the latest endocrine note listed, when a referral was declined — rather than against a condition or medication. It is not a bibliography for the other categories: no path leads from a fact to the document it was derived from. It is still where the verbatim wording lives — a narrative leaf under a condition carries reasoning, not note text — but getting from one to the other means finding the document here yourself.

Documents are **grouped by title** because a record repeats a title across many documents; a flat listing of an 87-document record spends most of itself on near-duplicate rows. Within a title, documents are ordered **newest first**, so the latest note of a kind is the first entry.

Ordering uses the document's authoring time. Clinical time is not inferred from an authoring date, so it is unavailable for most source documents.

Names are generated, not guessable: a document is named by an id, and a section file name is its title plus a short identity suffix. Browse a level before reading into it.

Two limits apply:

- A title lists at most **100 documents**. Any remainder is reported as a `_more` entry stating how many were withheld. A withheld document is reached only through a [`search_patient`](https://docs.clinia.com/api/mcp/tools/search-patient) match on one of its sections.
- Content is returned **as ingested**. Sections originating from marked-up documents read back with their markup, and line structure is preserved rather than reflowed.

## File types [#file-types]

### `_story.md` [#_storymd]

A prose Markdown narrative assembled from the entity's fields, codes, and relationships. For conditions, this is the primary high-value path for multi-hop clinical questions: it includes onset, medications under their status (active ones with their dosage), monitoring results by date, complications, comorbidities, and a timeline of key events. It closes with a `## Narratives` section linking each entry under `_narratives/`, with the verdicts that narrative holds. The section is omitted in `compact`.

Typically 300–800 tokens in `narrative` format.

## Read format and token budget [#read-format-and-token-budget]

All file paths can be read via `GET /v1/patients/{patientId}/read?path=...`. The `format` query parameter controls output verbosity:

| Format       | Output         | Approx. tokens |
| ------------ | -------------- | -------------- |
| `narrative`  | Prose Markdown | 300–800        |
| `structured` | Full JSON      | 200–500        |
| `compact`    | Key facts only | 50–150         |

`structured` on a file returns its fields as JSON. A condition's `_story.md` adds the story's related records, listed by id. `structured` on a directory returns its listing. The JSON does not include provenance — to see which extracted facts a value rests on, walk the patient graph as in [Trace a fact to the extracted facts behind it](https://docs.clinia.com/docs/trust-and-governance/audit-the-graph#trace-a-fact-to-the-extracted-facts-behind-it).

The `token_budget` parameter sets an approximate upper bound. Use it in multi-step agent workflows where context window budget is tracked explicitly. It applies to `narrative` and `compact` only: with `format=structured` the read is rejected with `400`, since JSON cut to a budget would not parse.

## Browse vs. read [#browse-vs-read]

| Operation | Endpoint                                     | Use when                                                                              |
| --------- | -------------------------------------------- | ------------------------------------------------------------------------------------- |
| Browse    | `GET /v1/patients/{patientId}/vfs?path=...`  | Discovering what exists at a path (returns directory children or inline file content) |
| Read      | `GET /v1/patients/{patientId}/read?path=...` | Fetching a specific file with format control (always returns `{ content: string }`)   |

For directory paths, browse and read return the same children listing. For file paths, read gives explicit format and token budget control; browse returns the file content at the default format.

## Paths that hold nothing [#paths-that-hold-nothing]

A path whose segment can never name anything returns `404`: an unknown status, an id with no record, or a year that is not a number, such as `/encounters/abcd`.

A path that could hold something but does not answers as empty instead. A year with no events (`/timeline/1999`) or a document title with no documents lists no children, and a lab test with no results reads `No lab trends found.`

See [Browse and Read VFS Paths](https://docs.clinia.com/docs/context-assembly/read-condition-story) for usage examples.
