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

> Report on the history entries recorded in your patients' charts.

One row per history entry recorded in a patient's chart. History entries cover past medical and surgical history, social history, habits, family history, smoking status, health maintenance notes and more. The `type` column identifies which kind of entry each row is.

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

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

* Health maintenance notes recorded in the chart
* Family history by relative, including the condition recorded against each one
* Smoking status per patient
* Past medical and past surgical history
* Who recorded each entry and when

<Note>
  Two `type` values overlap with dedicated tables. `Maintenance` rows are health maintenance **notes** typed into the chart; completed preventive care measures, with their measure codes and result flags, are in [health\_maintenance](/articles/hdb/health-maintenance). Likewise `Immunization` rows are free-text notes, not administered vaccines - those are in `patient_immunization`.
</Note>

## Entry types

| `type`          | What it holds                                               |
| --------------- | ----------------------------------------------------------- |
| `Past`          | Past medical history                                        |
| `Surgical`      | Past surgical history                                       |
| `Social`        | Social history                                              |
| `Habits`        | Habits                                                      |
| `Diet`          | Diet                                                        |
| `Exercise`      | Exercise                                                    |
| `Legal`         | Legal history                                               |
| `Consultation`  | Consultation history                                        |
| `Immunization`  | Free-text immunization notes                                |
| `Maintenance`   | Health maintenance notes                                    |
| `Cognitive`     | Cognitive status                                            |
| `Functional`    | Functional status                                           |
| `Psychological` | Psychological history                                       |
| `Family`        | Family history, both structured entries and free-text notes |
| `SmokingStatus` | The patient's recorded smoking status                       |

`Family` entries come from two places. Structured family history entries populate `relationship_type`, plus `icd9_id` or `snomed_id` where the clinician selected a code. Free-text notes filed under family history leave `relationship_type` null. Filter on `relationship_type is not null` when you want only the structured entries.

Deleted entries are retained with `deletion_time` set. Filter on `deletion_time is null` for the entries currently visible in the chart.

## Health maintenance notes

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

* Health maintenance notes per patient, in the order they appear in the chart
* Which clinician recorded each note and when

<CodeGroup>
  ```sql Health maintenance notes with patient and author theme={null}
  select
      ph.id as "PATIENT_HISTORY_ID"
    , ph.patient_id
    , pt.first_name as "PATIENT_FIRST_NAME"
    , pt.last_name as "PATIENT_LAST_NAME"
    , pt.dob as "PATIENT_DOB"
    , ph.value as "NOTE"
    , ph.rank as "DISPLAY_ORDER"
    , ph.creation_time
    , concat(c_user.first_name, ' ', c_user.last_name) as "CREATED_BY"
  from patient_history ph
    join patient pt on pt.id = ph.patient_id
    left join user c_user on c_user.id = ph.created_by_user_id
  where ph.type = 'Maintenance'
    and ph.deletion_time is null
  order by ph.patient_id, ph.rank;
  ```
</CodeGroup>

## Family history

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

* Conditions recorded against each relative
* Family history prevalence across your patient panel

<CodeGroup>
  ```sql Structured family history by relative theme={null}
  select
      ph.patient_id
    , pt.first_name as "PATIENT_FIRST_NAME"
    , pt.last_name as "PATIENT_LAST_NAME"
    , pt.dob as "PATIENT_DOB"
    , ph.relationship_type
    , ph.value as "CONDITION"
    , ph.icd9_id
    , ph.snomed_id
    , ph.creation_time
  from patient_history ph
    join patient pt on pt.id = ph.patient_id
  where ph.type = 'Family'
    and ph.relationship_type is not null
    and ph.deletion_time is null
  order by ph.patient_id, ph.rank;
  ```
</CodeGroup>

## Entry volume by type

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

* Which parts of the history section your practice uses most
* How many patients have any entry of a given type

<CodeGroup>
  ```sql Entry counts by type theme={null}
  select
      ph.type
    , count(*) as "ENTRIES"
    , count(distinct ph.patient_id) as "PATIENTS"
  from patient_history ph
  where ph.deletion_time is null
  group by ph.type
  order by "ENTRIES" 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>*
