# Preview a template

## Overview

This flow describes how to preview a [report template](https://docs.ohc.network/concepts/platform/report-template.md) in the **Template Builder**. Care fills the template with sample values, so you can check the layout.

[Video: Preview a template](https://www.youtube.com/watch?v=H8WQR4lkHF8)

## Pre-requisites

* You create a new report template, or you edit an existing report template.
* You have the permissions listed below.

## Permissions

| Permission | Access |
| - | - |
| Can Preview Template | Lets you preview the template. You can hold it in any organization of any facility. Only Facility Admin has it by default. |
| Can Read Template | Shows **Templates** in the facility settings and lists the templates. You can hold it in any organization of the facility. Facility Admin, Administrator, Staff, Doctor, Nurse, Volunteer and Pharmacist have it by default. |
| Can Create Template on Facility | Shows **Create Template** and the **Edit** button on each card, which open the **Template Builder**. Facility Admin, Doctor and Nurse have it by default. |
| Can View Template Schema | Loads the contexts and their fields in the **Template Builder**. You can hold it in any organization of any facility. Only Facility Admin has it by default. |

By default, only a Facility Admin has all of these permissions. A Doctor or a Nurse does not have Can Preview Template or Can View Template Schema by default.

## Steps

### 1. Open the template in the builder

Create a new report template, or open an existing template with **Edit**. Care shows the **Template Builder**.

See [Create a report template](https://docs.ohc.network/flows/platform/report-template/create-a-report-template.md) or [Edit a report template](https://docs.ohc.network/flows/platform/report-template/edit-a-report-template.md).

![The Templates page with the template cards, and the Edit button of the Discharge Summary card outlined](/assets/images/preview-a-template-1-2e48dcc4e8c9bb159a079eaa7f433cbc.webp)

### 2. Select the context and the format

In **Select Context**, select the context that matches the report type. The preview uses this context.

In **Default Format**, select the format to preview: HTML or PDF. The preview uses this format.

Note: If people print the report, preview it as PDF. Only PDF reports open and print in Care.

Note: If you change **Default Format** and save the template, new reports use the new format.

![The Template Builder with Encounter Report in Select Context and PDF selected in the outlined Default Format box](/assets/images/preview-a-template-2-693047ba0931c0a1762000aaddf40224.webp)

### 3. Preview the template

Select **Preview Template**.

Care fills the template with sample values. It does not use the data of a real patient, encounter, or billing account.

Each list in the template shows one to four sample rows. The number of rows can change each time.

![The Template Builder with the Preview Template button outlined](/assets/images/preview-a-template-3-e6b61d228ba8852b8dd3f9e9891af6aa.webp)

### 4. Check the preview

Care shows the message "Template preview generated successfully".

The preview replaces the template body in the builder. Its heading is **Preview Template**.

An HTML preview shows in the page, without scripts. A PDF preview shows in a frame.

Read the preview. Check the layout and the wording.

![The Template Builder with the message Template preview generated successfully, and the PDF preview outlined under the Preview Template heading](/assets/images/preview-a-template-4-ffbc5cbe65fd1307362430d7c431688c.webp)

### 5. Go back to the template body

Select **Clear Preview**. Care shows **Template HTML** again.

Note: **Preview Template** is not available while the preview shows.

![The Template Builder showing the preview, with the Clear Preview button outlined](/assets/images/preview-a-template-5-64d1b738fc4a6737af2621312514ac8d.webp)

### 6. Correct any errors

If the template body has an error, the preview fails.

Correct the template body in **Template HTML**. Then select **Preview Template** again.

Note: The preview does not save the template. To keep your changes, select **Save Template**.

![The Template Builder showing the template body in the Template HTML box again, next to the Fields card](/assets/images/preview-a-template-6-5e7670ee581ff023c0ccaf9f0e3b37a5.webp)

## Expected Outcome

* Care shows the message "Template preview generated successfully".
* Care shows the template filled with sample values, in HTML or PDF.

## Related

Concepts:

* [Report Template](https://docs.ohc.network/concepts/platform/report-template.md)

Flows:

* [Create a report template](https://docs.ohc.network/flows/platform/report-template/create-a-report-template.md)
* [Edit a report template](https://docs.ohc.network/flows/platform/report-template/edit-a-report-template.md)
* [View report templates](https://docs.ohc.network/flows/platform/report-template/view-report-templates.md)
* [Generate and view a report](https://docs.ohc.network/flows/platform/report-template/generate-and-view-a-report.md)
* [Print a report](https://docs.ohc.network/flows/platform/report-template/print-a-report.md)
