# Generate a token for an appointment

## Overview

[Video: Generate a token for an appointment](https://www.youtube.com/watch?v=hL-1dhvtyUY)

This flow describes how to give a patient a [token](https://docs.ohc.network/concepts/scheduling/token.md) for an appointment with a practitioner. The token puts the patient in a queue for that practitioner.

## Pre-requisites

* You are a member of the facility.
* The patient has an [appointment](https://docs.ohc.network/concepts/scheduling/booking.md) at the facility, and the appointment has no token yet. An appointment can have only one token, even after that token is cancelled.
* If the appointment is Cancelled, Entered in Error, Rescheduled, No Show or Fulfilled, Care does not offer **Generate Token**.
* A token category exists for the practitioner resource type. See [Create a token category](https://docs.ohc.network/flows/scheduling/token/create-token-category.md).
* You have the permissions listed below.

## Permissions

| Permission | Access |
| - | - |
| Can update bookings on Object | Lets you generate the token. When you save, Care checks this permission and no token permission. Hold it where the paragraph below the table says. Without it, Care shows "You do not have permission to update bookings". By default, the Staff, Facility Admin, Doctor and Nurse roles hold it. The Administrator role does not hold it. |
| Can Create on Token | Shows **Generate Token** on the appointment page. It does not let you generate the token without "Can update bookings on Object". Hold it in the Administration organization, which every facility has, or in a department or team of the facility. By default, the Staff, Facility Admin, Doctor, Nurse and Administrator roles hold it. |
| Can list bookings on Object | Lets you see **Appointments** in the facility sidebar, and list and open the appointments of the practitioner. For the sidebar item and the appointment page, hold it in the Administration organization, or in a department or team. To list and open the appointments, also hold it where the paragraph below the table says. By default, the Staff, Facility Admin, Doctor, Nurse and Administrator roles hold it. |
| Can list token category on Facility | Lets you see the token categories in the **Generate Token** form. Hold it in the Administration organization, or in a department or team of the facility. By default, the Staff, Facility Admin, Doctor, Nurse and Administrator roles hold it. |

Care checks "Can update bookings on Object" and "Can list bookings on Object" for the practitioner of the appointment. Hold them in the Administration organization, in a [facility organization](https://docs.ohc.network/concepts/access-governance/facility-organization.md) that the practitioner belongs to, or in an organization above it.

## Steps

### 1. Open the appointment

* In the facility sidebar, under **Patient Management**, select **Appointments**.
* Choose the practitioner of the appointment. The page lists the appointments of that practitioner.
* Open the patient's appointment. The appointment page has a **Token** section.

![The Appointments board with Dr. Meera Iyer chosen under Practitioners and the patient\&#39;s booked appointment outlined in the Booked column](/assets/images/generate-token-for-appointment-1-afb4e0c567de1ddf2a9be8e1b9d1d75d.webp)

### 2. Select Generate Token

* In the **Token** section, find the **Token not generated** panel.
* Select **Generate Token**. You can also press T.
* Care opens the **Generate Token** form.
* If the **Token** section shows a token card, the appointment already has a token. A token that is finished or cancelled still shows, with a badge such as **Fulfilled** or **Cancelled**. Care does not offer **Generate Token** again.
* If the **Token** section shows no panel and no token card, check the appointment status and your permissions.

![The Token section of the appointment page showing Token not generated and the Generate Token button](/assets/images/generate-token-for-appointment-2-e23e151dad5f1545f667f671becda759.webp)

### 3. Check the token category

* The **Token Category** field lists the token categories for practitioners.
* Care selects the default category and marks it "(Default)".
* If the practitioner resource type has no default category, Care selects no category. Select one from the list.
* To use a different category, select it from the list.

![The Generate Token form with the token category General Consultation selected from the list](/assets/images/generate-token-for-appointment-3-9487b4f05778abd0afaa08f9ba6df067.webp)

### 4. Add a note

* Optionally, enter a **Note**.

### 5. Generate the token

* Select **Generate Token**.
* The button stays disabled until you select a category.
* Care shows "Token generated successfully".

![The token card GEN-009 on the appointment page with the three-dot Token actions button, the QR code, Queue Board and Print Token, after the token is generated](/assets/images/generate-token-for-appointment-4-d05b41e3feab759113ca53171a43a81a.webp)

## Expected Outcome

* The **Token** section of the appointment page shows the token card.
* The token card shows a QR code that holds the patient's ID. **Scan QR** on the appointment bar of an encounter reads this code.
* The token card has **Queue board**, which opens the queue of the token, and **Print Token**.
* Your deployment can add fields for a patient; filled ones print on the token card below the patient's age and gender, but do not show on screen.
* The token card has a three-dot button with **Cancel Token**. It shows while the token is Created, In Progress or Unfulfilled. See [Cancel a token](https://docs.ohc.network/flows/scheduling/token/cancel-token.md).
* The token is linked to the appointment and to the patient.
* Care puts the token in a queue that Care generates for the practitioner and the date of the appointment. Care never uses a queue that staff create.
* If Care has not generated that queue yet, Care creates it. On the queue list, this queue has the title **Primary Queue**.
* Care counts token numbers separately for each category in the queue. The number starts with the shorthand of the category, for example GEN-007.
* The appointments list shows the token number for the appointment.
* If the appointment is cancelled or rescheduled later, its token does not change. The token stays in its queue. If it is not served yet, **Serve Next Patient** can still call it. To take it out of the queue, cancel the token. See [Cancel a token](https://docs.ohc.network/flows/scheduling/token/cancel-token.md).

## Related

Concepts:

* [Token](https://docs.ohc.network/concepts/scheduling/token.md)
* [Appointment Booking](https://docs.ohc.network/concepts/scheduling/booking.md)
* [Facility Organization](https://docs.ohc.network/concepts/access-governance/facility-organization.md)

Flows:

* [Create a token category](https://docs.ohc.network/flows/scheduling/token/create-token-category.md)
* [Create a token without an appointment](https://docs.ohc.network/flows/scheduling/token/create-token.md)
* [Serve patients from a token queue](https://docs.ohc.network/flows/scheduling/token/manage-token-queue.md)
* [Cancel a token](https://docs.ohc.network/flows/scheduling/token/cancel-token.md)
* [View and print a patient's tokens](https://docs.ohc.network/flows/scheduling/token/view-patient-tokens.md)
