> ## 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.

# Bill

> Query the EHR-side bill a practice generates from a visit note - its billing status, the providers on it, and the Elation Billing claim it produced.

One row per bill generated from a visit note - the EHR-side billing record a practice creates to capture what was billed for an encounter. Each bill links to its `visit_note` (and, through the note, the `patient`), `practice`, and `service_location`, and carries the billing-section provider roles and the current billing status. On the Elation Billing side, a `claim` points back to the bill it was generated from via `claim.bill_id`.

The CPT lines billed on a bill live in `bill_item` (`bill_item.bill_id` → `bill.id`), and their diagnosis pointers in `bill_item_dx` (`bill_item_dx.bill_item_id` → `bill_item.id`).

The table schema can be found in our [HDB dbdocs reference](https://dbdocs.io/hosteddb_support/hosted_database_snowflake?view=bill).

**For reporting on but not limited to:**

* What was billed for a patient's visit, and when (`billing_date`)
* Bill status and any billing errors (`billing_status`, `billing_status_detail`, `billing_error`)
* The rendering, supervising, and billing providers on a bill
* Reconciling EHR bills to Elation Billing claims via `claim.bill_id`
* CPT- and diagnosis-level detail by joining `bill_item` and `bill_item_dx`

<Note>
  `rendering_provider_id` is only populated when the rendering provider **differs from the note's provider**. When it is null, the rendering provider is the visit note's author - `visit_note.physician_user_id`. To get the effective rendering provider, fall back to the note's author whenever `rendering_provider_id` is empty (see [Effective rendering provider](#effective-rendering-provider) below).

  Watch the join keys: the provider-role columns on `bill` (`rendering_provider_id`, `supervising_provider_id`, `billing_provider_id`, `referring_provider_id`) join to `user` on `user.physician_id`, whereas `visit_note.physician_user_id` joins to `user.id`. Divergence between the note's provider and the rendering provider is common in practices with supervising relationships or incident-to billing (`incident_to = true`).
</Note>

## Bills for a date range

Returns every bill with a billing date in a window, with its status, reference number, and any billing error.

<CodeGroup>
  ```sql sql theme={null}
  select
      b.id as bill_id
    , b.practice_id
    , b.visit_note_id
    , b.service_location_id
    , b.billing_date
    , b.billing_status
    , b.billing_status_detail
    , b.ref_number
    , b.billing_error
  from bill b
  where b.billing_date between '2026-01-01' and '2026-03-31'
  order by b.billing_date, b.practice_id;
  ```
</CodeGroup>

## Effective rendering provider

Resolves the provider who rendered the services on each bill. Because `rendering_provider_id` is only set when it differs from the note's author, this falls back to `visit_note.physician_user_id` when the column is empty. Note the two joins to `user` use different keys.

<CodeGroup>
  ```sql sql theme={null}
  select
      b.id as bill_id
    , b.visit_note_id
    , vn.patient_id
    , b.rendering_provider_id
    , coalesce(rp.id, np.id) as effective_rendering_provider_user_id
    , coalesce(
          rp.first_name || ' ' || rp.last_name
        , np.first_name || ' ' || np.last_name
      ) as effective_rendering_provider_name
    , case when b.rendering_provider_id is null
        then 'note author' else 'bill override' end as source
  from bill b
    join visit_note vn on vn.id = b.visit_note_id
    left join user np on np.id = vn.physician_user_id
    left join user rp on rp.physician_id = b.rendering_provider_id
  where vn.deleted_by_user_id is null
  order by b.billing_date desc;
  ```
</CodeGroup>

## Bill volume by status

Rolls up bill counts by practice and billing status over the last 90 days. `billing_status_detail` is the full status shown in Billing Home; `billing_status` is the collapsed category.

<CodeGroup>
  ```sql sql theme={null}
  select
      b.practice_id
    , b.billing_status_detail
    , count(*) as bills
  from bill b
  where b.billing_date >= dateadd(day, -90, current_date)
  group by b.practice_id, b.billing_status_detail
  order by b.practice_id, bills desc;
  ```
</CodeGroup>

## Reconcile a bill with its claim

Joins each EHR bill to the Elation Billing claim it produced via `claim.bill_id`, so you can confirm which bills made it to a claim and which have not.

<CodeGroup>
  ```sql sql theme={null}
  select
      b.id as bill_id
    , b.visit_note_id
    , b.billing_date
    , b.billing_status_detail
    , c.id as claim_id
    , c.local_id
    , c.is_billed
  from bill b
    left join claim c
      on c.bill_id = b.id
      and c.is_deleted = false
  where b.billing_date >= dateadd(day, -30, current_date)
  order by b.billing_date desc;
  ```
</CodeGroup>

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