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

# Payment

> Query insurance and patient payments recorded in Elation Billing - amounts, dates, and how they apply to claims.

One row per payment recorded in Elation Billing, from both insurance payers and patients. Each payment carries its amount, dates, type and method, and how much has been applied to charges. Insurance payments have no EHR equivalent, so `patient_id` and `claim_id` are often empty.

This table's columns and relationships are shown in the [Hosted Database schema](/articles/hdb/schema).

<Note>
  `patient_id` and `claim_id` are both nullable - insurance payments frequently have neither. To reach the ERA behind a payment, join `claimmd_era_id` to [`era_matched_adjustment`](/articles/hdb/era-matched-adjustment) on its `claimmd_era_id`.
</Note>

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

* Total payments received by practice or date
* Insurance vs patient payments (`pay_type`)
* Applied vs unapplied payment amounts
* Co-pays (`is_copay`)

## Payments by practice and month

<CodeGroup>
  ```sql sql theme={null}
  select
      p.practice_id
    , date_trunc('month', p.payment_date) as payment_month
    , count(*) as payments
    , sum(p.amount) as total_amount
  from payment p
  where p.is_deleted = false
  group by p.practice_id, payment_month
  order by payment_month desc;
  ```
</CodeGroup>

## Unapplied payment balances

<CodeGroup>
  ```sql sql theme={null}
  select
      p.practice_id
    , p.id as payment_id
    , p.amount
    , p.applied_amount
    , p.unapplied_amount
  from payment p
  where p.is_deleted = false
    and p.unapplied_amount > 0
  order by p.unapplied_amount desc;
  ```
</CodeGroup>

## Payments with their ERA adjustment detail

<CodeGroup>
  ```sql sql theme={null}
  select
      p.id as payment_id
    , p.claim_id
    , p.amount
    , e.adjustment_group
    , e.adjustment_code
    , e.adjustment_amount
  from payment p
    join era_matched_adjustment e on e.claimmd_era_id = p.claimmd_era_id
  where p.is_deleted = false
    and p.claimmd_era_id is not null;
  ```
</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>*
