> ## Documentation Index
> Fetch the complete documentation index at: https://help.elationhealth.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Visit Notes

> How visit notes are modeled in the hosted database: the note record, its content, and how it relates to patients, bills, orders, and documents.

A visit note is Elation's record of a clinical encounter. In the hosted database each note is modeled as two tables: a record for the note itself and a set of rows for its content.

* **`visit_note`**: one row per visit note, holding the note's metadata (patient, practice, author, sign-off, and timing).
* **`visit_note_bullet`**: one row per line of content within a note, joined to its note by `visit_note_bullet.visit_note_id = visit_note.id`.

For the full column list of every table mentioned here, see the [hosted database schema reference](https://help.elationhealth.com/articles/hdb/where-can-i-see-what-data-is-available.md).

## Note content

A note's content is stored as bullets in `visit_note_bullet`. Each bullet has:

* a **`category`** naming the section it belongs to (Reason, HPI, Assessment, Plan, Orders, and so on),
* a **`sequence`** giving its order within that section, and
* an optional **`parent_bullet_id`**, since bullets can be nested under a parent.

A bullet carries its content in one of two ways. Most bullets hold **typed prose** directly in `text`: the narrative a clinician writes in sections like Reason, HPI, Assessment, and Plan. Other bullets instead **reference a separate record** (a placed order, an attached or referenced document, or a problem-list item); their `text` is empty because the content lives in that linked record rather than on the bullet.

## How visit notes relate to other data

Visit notes connect to the wider data model through these relationships:

| Related data | Relationship |
| - | - |
| **Patient** | `visit_note.patient_id` → `patient.id` |
| **Authoring / signing user** | `visit_note.physician_user_id`, `signed_by_user_id`, `created_by_user_id` → `user.id` |
| **Bills** | `bill.visit_note_id` → `visit_note.id`. The billing-section provider roles live on `bill` itself (`rendering_provider_id`, `supervising_provider_id`, `billing_provider_id`, `referring_provider_id`) — `visit_note.physician_user_id` is the note's author and is not necessarily the rendering provider on the bill. See [Visit Notes and Bills](https://help.elationhealth.com/articles/hdb/visit-notes-and-bills.md). |
| **Document tags** | `visit_note_document_tag.visit_note_id` → `visit_note.id` |
| **Orders** (medication, lab, referral, imaging, cardiac, sleep, and pulmonary) | `visit_note_id` on `lab_order`, `med_order`, `discontinue_med_order`, `referral_order`, and `misc_orders` → `visit_note.id`, for orders placed from the note. See [Orders placed from a note](#orders-placed-from-a-note). |
| **Other referenced documents** (lab reports, attachments) | The link between a bullet and the document it references is not exposed in the hosted database. Where the content has its own patient-level table (such as `lab_result`), query it by patient; otherwise it is not available through the note. |

## Orders placed from a note

Each order table carries two columns naming the note the order was placed from:

* **`visit_note_id`** joins to `visit_note.id`.
* **`non_visit_note_id`** joins to `non_visit_note.id`, for orders placed from a non-visit note such as a phone note.

Both columns are empty for an order created outside a note. The order tables are `lab_order`, `med_order`, `discontinue_med_order`, `referral_order`, and `misc_orders` (imaging, cardiac, sleep, and pulmonary orders).

This returns the lab orders placed from each visit note:

```sql sql theme={null}
select
    vn.id as visit_note_id
  , vn.document_date
  , vn.physician_user_id
  , lo.id as lab_order_id
  , lo.date_for_test
from lab_order lo
  join visit_note vn on vn.id = lo.visit_note_id
where lo.deletion_time is null
  and vn.deletion_time is null;
```

This counts prescriptions placed outside any note:

```sql sql theme={null}
select count(*) as prescriptions_outside_a_note
from med_order
where origin = 'rx'
  and visit_note_id is null
  and non_visit_note_id is null
  and deletion_time is null;
```

* Filter `med_order.origin = 'rx'` to count prescriptions. Rows with `origin = 'surescripts'` are imported medication history and never carry a note.
* Count orders in `misc_orders` with `count(distinct id)`. The table has one row per order for each test and diagnosis code on it.

## Confidential notes

`visit_note.confidential` and `non_visit_note.confidential` are `true` when the note is marked confidential in the chart, and `confidential_marked_by_user_id` names the user who marked it. This lists confidential visit notes signed in a month:

```sql sql theme={null}
select
    vn.id as visit_note_id
  , vn.patient_id
  , vn.document_date
  , vn.confidential_marked_by_user_id
from visit_note vn
where vn.confidential
  and vn.deletion_time is null
  and vn.signed_time >= '<month_start>'
  and vn.signed_time < '<next_month_start>';
```

## Reading a note's content

This returns every content line for a single note, in display order:

```sql sql theme={null}
select
    b.visit_note_id
  , b.category
  , b.sequence
  , b.text
from visit_note_bullet b
where b.visit_note_id = <visit_note_id>
  and b.is_deleted = false
order by b.category, b.sequence;
```

Bullets that reference a separate record (such as placed orders) return empty `text`; retrieve that content from the related tables described in [How visit notes relate to other data](#how-visit-notes-relate-to-other-data).

*If you have any questions about this topic please reach out to [Elation Support Portal](https://help.elationhealth.com/articles/support-portal-introduction.md) with the subject line HDB - \<your\_question>*
