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

# Patient forms

> The patient forms a practice has built in Elation, with each form's name, type, and position in the practice's form list.

The `patient_form` table has one row per patient form a practice has built in Elation: intake questionnaires, medical history forms, and similar. It holds the form's name, the heading the patient sees, its type and position in the practice's form list, and who created, last edited, or deleted it. Join to `practice` on `practice_id`.

This is the table the rest of the patient forms tables point at. `patient_form_request_form`, `patient_form_submission`, `patient_form_appointment_type`, and `patient_form_appointment_change` all carry a `patient_form_id` that joins to `id` here for the form's name. For how practices build and use forms, see the [Patient Forms Guide](https://help.elationhealth.com/articles/Patient-Forms-Guide.md).

This table's columns and relationships are shown in the [Hosted Database schema](https://help.elationhealth.com/articles/hdb/schema.md).

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

* The forms a practice has, in the order Elation shows them
* How many submissions each form has, and which forms are no longer used
* Which forms are required by appointment types and which are sent ad-hoc
* When forms were added, renamed, or retired

## Before you query patient forms

### A form has two names

`name` is the label the practice sees in its own form list. `title` is the heading the patient sees at the top of the form. The two differ on most forms, so pick the one that suits the audience: `name` when reporting to practice staff, `title` when reporting on what the patient was asked to fill in. A form with no `name` at all appears in Elation as **Patient Form Submission**.

### A form counts while `deletion_time` is null

Deleted forms are kept so that earlier requests and submissions can still show a name. Filter on `deletion_time is null` for a practice's current form list, and leave the filter off when you are reporting on past activity, where a form the practice has since retired still needs a name.

### Elation's order is `sequence`, then `id`

Sort by `sequence`, then `id`, to match the order Elation shows a practice's forms in. Two forms can share a `sequence`, which is why the tie-break on `id` matters.

### The name is always the form's current name

Renaming a form changes the name shown against its earlier requests and submissions too. There is no history of previous names, so a report run today and the same report run last year can label the same form differently.

### History starts on 2024-07-11

Forms created before 2024-07-11 and not edited since may be missing, along with their submissions. The rare form that belongs to a practice outside your Hosted Database is missing as well. Left join `patient_form` when all you want is a name, so rows whose form is missing are kept rather than dropped.

### Questions and answers are not included

Only the form's metadata is here. The questions on a form, and the answers a patient gave, are not in the Hosted Database. `patient_form_submission.report_id` points at the chart document the submission created, which is where the answers live in Elation.

## A practice's forms in Elation's order

Returns one practice's current forms in the order Elation lists them, with both names.

```sql sql theme={null}
select
    f.sequence
  , f.id as patient_form_id
  , f.name as staff_facing_name
  , f.title as patient_facing_title
  , f.form_type
  , f.allow_staff_signoff
  , f.creation_time
  , f.last_modified
from patient_form f
where f.practice_id = <practice_id>
  and f.deletion_time is null
order by f.sequence, f.id;
```

## Submissions per form

Counts submissions for every form, including forms the practice has since deleted, so that older activity is not lost. Forms with no submissions come back with a count of zero.

```sql sql theme={null}
select
    f.practice_id
  , pr.name as practice_name
  , f.id as patient_form_id
  , f.title as form_title
  , f.form_type
  , iff(f.deletion_time is null, 'active', 'deleted') as form_status
  , count(s.id) as submissions
  , count(distinct s.patient_id) as patients
  , max(s.creation_time) as last_submitted
from patient_form f
  left join practice pr on pr.id = f.practice_id
  left join patient_form_submission s
    on s.patient_form_id = f.id
   and s.deletion_time is null
group by f.practice_id, pr.name, f.id, f.title, f.form_type, f.deletion_time
order by submissions desc;
```

## How each form reaches patients

Shows, for one practice's current forms, how many appointment types require each one and how many ad-hoc requests have included it. A form with neither is built but unused.

```sql sql theme={null}
select
    f.id as patient_form_id
  , f.name as form_name
  , f.sequence
  , count(distinct t.appt_type_id) as appointment_types_requiring
  , count(distinct rf.patient_form_request_id) as ad_hoc_requests
  , count(distinct s.id) as submissions
from patient_form f
  left join patient_form_appointment_type t
    on t.patient_form_id = f.id
   and t.deletion_time is null
  left join patient_form_request_form rf
    on rf.patient_form_id = f.id
   and rf.deletion_time is null
  left join patient_form_submission s
    on s.patient_form_id = f.id
   and s.deletion_time is null
where f.practice_id = <practice_id>
  and f.deletion_time is null
group by f.id, f.name, f.sequence
order by f.sequence, f.id;
```

*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>*
