---
title: "Cancel appointment, action later (A022, FHIR STU3)"
method: POST
path: "/STU3/ReferralRequest/{ubrn}/$ers.cancelAppointmentActionLater"
tags: ["Review referral requests"]
---

# Cancel appointment, action later (A022, FHIR STU3)

`POST /STU3/ReferralRequest/{ubrn}/$ers.cancelAppointmentActionLater`

## Request

- Base URL: `https://sandbox.api.service.nhs.uk/referrals/FHIR`
- URL: `https://sandbox.api.service.nhs.uk/referrals/FHIR/STU3/ReferralRequest/{ubrn}/$ers.cancelAppointmentActionLater`
- Auth: HTTP bearer

## Overview
Use this endpoint, as a service provider, to task your admin team to rebook/redirect a referral that is booked 
into your bookable service and awaiting review.

Note: this will also cancel the current appointment.

Whilst a document can be uploaded via [[HYPERLINK_A020]] without a `NHSD-eRS-Referral-ID`, only documents that have a `NHSD-eRS-Referral-ID` can be associated using this end point. 
An attempt to associate a document without a `NHSD-eRS-Referral-ID` will return an error response of 422 - `INAPPROPRIATE_VALUE`.

## Supported security patterns
- Healthcare worker, user-restricted access

## Pre-requisites
In order to use this endpoint you must be an authenticated e-RS user and use one of the following e-RS roles:
  - `SERVICE_PROVIDER_CLINICIAN`
  - `SERVICE_PROVIDER_CLINICIAN_ADMIN`

You need to use [[HYPERLINK_A008]] to retrieve the contents of the 'Referrals For Review' worklist. [[HYPERLINK_A022]] can 
only be used for referrals booked into bookable services, and not the referrals sent into triage services.

You need to use [[HYPERLINK_A005]] to retrieve the details for the referral.

You need to use [[HYPERLINK_A006]] to retrieve the clinical attachments for the referral.

You need to use [[HYPERLINK_A007]] to retrieve the clinical information summary PDF for the referral.

If you want to include attachments with the admin task, you need to use [[HYPERLINK_A020]] so they are 
ready to be associated when this endpoint is called.

## Use cases
As an authenticated user

I need to task my admin team to rebook/redirect a referral I have reviewed (whilst also cancelling the current appointment)

So that I can progress the patient's care along the most appropriate referral pathway.

## Important notes
  - The priority of the referral can be changed as part of this endpoint.
  - A comment must be added to explain to the administrator what is required and can include optional attachments.
  - The current appointment is cancelled as part of this endpoint. If the current appointment is booked to an indirectly
    bookable service, you must indicate whether the appointment has been cancelled on the local provider system. 
    If indicated as not cancelled, the referral will be added to the 'Indirectly Booked Appointments to Cancel in PAS' 
    worklist to task the admin team to do so.
  - When this endpoint is successfully used, an entry will be added to the service providers 'Appointments For Booking' 
    worklist for the admin team to action the task. The provider admin team will only be able to progress the referral 
    via the e-RS Professional Application user interface (e.g. shortlisting appropriate services for the patient).
  - In order to retrieve an attachment using the [[HYPERLINK_A042]] (or deprecated [[HYPERLINK_A006]]) endpoint, the attachment must be available for download. 
    The availability status of attachments associated with a referral are returned via this endpoint as a eRS-AvailabilityStatus-1 code.
    - Further details on attachment availability status and eRS-AvailabilityStatus-1 codes can be found in the [[HYPERLINK_A005]] and [[HYPERLINK_A042]] specifications.

## Known Issues

1. The Participant.type attribute is being mapped as a single type for this endpoint. As per the Appointment [FHIR profile](https://hl7.org/fhir/STU3/appointment-definitions.html#Appointment.participant.type), this attribute should be an array. See our [problems and fixes](https://digital.nhs.uk/services/e-referral-service/api/updates-and-releases/problems-and-fixes) section for more information.
2. The participant of an Appointment references a value set. As per the Appointment [FHIR profile](https://hl7.org/fhir/STU3/appointment-definitions.html#Appointment.participant.type), this attribute should be a coding system. See our [problems and fixes](https://digital.nhs.uk/services/e-referral-service/api/updates-and-releases/problems-and-fixes) section for more information.

## Parameters

- `#/paths/~1STU3~1Task/get/parameters/0` (unresolved $ref)
- `#/paths/~1STU3~1Task/get/parameters/1` (unresolved $ref)
- `#/paths/~1STU3~1Task/get/parameters/2` (unresolved $ref)
- `#/paths/~1STU3~1Task/get/parameters/3` (unresolved $ref)
- `#/paths/~1STU3~1Task/get/parameters/4` (unresolved $ref)
- `#/paths/~1STU3~1ReferralRequest~1%7Bubrn%7D/get/parameters/0` (unresolved $ref)
- `#/paths/~1STU3~1Appointment~1%7Bid%7D/put/parameters/5` (unresolved $ref)

## Request body

- object
  - `resourceType` 'Parameters', required
  - `meta` object, required
    - `profile` string[], required
  - `parameter` union[], required: | Field | Cardinality | Notes | | --------------------------------- | ----------- | ------------------------------------------------------- | | `priority` | `0..1` | Optionally updates the priority | | `appointmentCancelledinPAS` | `0..1` | This flag is mandatory for indirectly bookable services | | `comments` | `1..1` | | | `providerAttachmentFile` | `0..*` | |
    - union
      - object: Parameter to supply a priority
        - `name` 'priority', required
        - `valueCoding` ValueCoding, required (unresolved $ref)
      - object: Parameter to supply a appointmentCancelledInPAS
        - `name` 'appointmentCancelledInPAS', required
        - `valueBoolean` boolean, required
      - object: Parameter to supply the comments
        - `name` 'comments', required
        - `valueString` string, required
      - object: Parameter to supply an attachment file
        - `name` 'providerAttachmentFile', required
        - `resource` object, required: A reference to a document
          - `meta` object, required
            - `profile` string[], required
          - `resourceType` 'DocumentReference', required
          - `type` object, required
            - `coding` object[]
              - …
          - `status` 'current', required
          - `indexed` string, date-time, required
          - `description` string, nullable
          - `content` object[], required
            - `attachment` object, required
              - …

## Response `200`

e-RS Referral Request

- Schema (unresolved $ref)

## Other responses

- `400` (unresolved $ref)
- `401` (unresolved $ref)
- `403` (unresolved $ref)
- `404` (unresolved $ref)
- `406` (unresolved $ref)
- `409` (unresolved $ref)
- `412` (unresolved $ref)
- `415` (unresolved $ref)
- `422`: Where status code 422 (Unprocessable Entity) is returned then an eRS-OperationOutcome-1 will be included in the body, as detailed below. Check diagnostics property for specific information regarding the error. | Error code | Description | | ---------------------------------- | ---------------------------------------------------------------------------------------------------------------------------- | | INAPPROPRIATE_VALUE | A value, which is acceptable under different conditions, is inappropriate in the context of the other information provided. | | MISSING_VALUE | A field defined as mandatory for an endpoint has not been provided. | | INVALID_VALUE | The input provided does not conform to the expected data types and format. | | INVALID_CODE | The input provided for a field is not one of the defined legal values. | | VALUE_IS_REQUIRED | A business rule defines a value as mandatory but it has not been provided. | | FIELD_NOT_PERMITTED | A business rule defines a field as not permitted but it has been provided. | | INVALID_REQUEST_STATE | The Request, while otherwise valid, is not in the correct state for the specific action being performed. | | PATIENT_ERROR | An error occurred while retrieving the requested patient. Do not attempt again. | | NO_RELATIONSHIP | The user does not have a legitimate relationship with the request. | | REFERENCE_NOT_FOUND | A supplied reference could not be resolved to valid resource (e.g. a patient, clinician or an organisation). | | INVALID_STATE | Indicates that the referenced item is not in the correct state for the request to be processed. | | DUPLICATE_FILENAME | A file being attached, matches another file being attached, or matches a file that is already linked. |
- `423` (unresolved $ref)
- `429` (unresolved $ref)
- `500` (unresolved $ref)
- `503` (unresolved $ref)

---

[API](https://skmtc.dev/nhs/apis/e-referrals-service-api.md) - [All operations](https://skmtc.dev/nhs/apis/e-referrals-service-api/llms.txt) - [OpenAPI document](https://skmtc.dev/nhs/apis/e-referrals-service-api/revisions/916969ea472f?raw)
