Skip to content

SPEC CHANGE - WPP-11130 - Proposed changes to API specs for Invite to Book - #166

Draft
simeonparris-nhs wants to merge 50 commits into
masterfrom
apm-000-WPP-11130-proposed-task-changes-for-ItB
Draft

SPEC CHANGE - WPP-11130 - Proposed changes to API specs for Invite to Book#166
simeonparris-nhs wants to merge 50 commits into
masterfrom
apm-000-WPP-11130-proposed-task-changes-for-ItB

Conversation

@simeonparris-nhs

@simeonparris-nhs simeonparris-nhs commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Invite to Book - Task Resource Alignment Summary

Overview

To support the Invite to Book changes, the design has been made to uplift the existing Task resource to support both Invitations to Book and Questionnaires, along with being extensible for further use cases.

The Consumer API Task resource and Producer API Task resource have been aligned to support multiple use cases (questionnaires, appointment booking invites, and future task types) while maintaining backwards compatibility with the existing Questionnaire resource. However, there are intentional differences in field naming between the two APIs:

  • Consumer API uses code field for task type classification
  • Producer API uses reasonCode field for task type classification

This aligns the Consumer API spec more closely with FHIR standards.

Why This Change?

Previous Implementation

  • Questionnaire-centric: The Consumer Task resource was essentially a copy of the Questionnaire resource with additional fields for appointment booking invites
  • Limited extensibility: The kind enum was rigid and required updates for each new task type
  • Misaligned with Producer spec: The Consumer spec Task didn't follow the producer-side FHIR Task pattern
  • Redundancy: Similar fields and logic across Questionnaire and Task resources

New Implementation

  • Generic task framework: Task resource can represent any patient action (questionnaires, booking invites, etc.)
  • FHIR R4 aligned: Follows standard FHIR Task structure with fields like status, intent, reasonCode, reasonReference
  • Producer-spec aligned: Matches the Producer API standards for consistency across the aggregator ecosystem
  • Future-proof: Extensible via reasonCode and extensions for new task types
  • Cleaner architecture: Single generic Task resource instead of type-specific variants

Key Changes

Removed Fields

  • kind → Replaced by code in Consumer API, reasonCode in Producer API (FHIR standard, provides more semantic meaning)
  • scheduledPeriod → Replaced by restriction.period (FHIR standard)
  • performer → Replaced by owner (FHIR standard terminology)

Added Fields

Field Type Required Purpose
id string Yes Globally unique identifier for the task
identifier object No System-specific identifier (portal database ID)
intent string Yes Always "plan" - indicates task intent
authored date-time Yes When task became available to patient
lastModified date-time No When task was last modified by patient
restriction.period object No Start/end dates for task deadline
focus object No Reference to linked Appointment (if applicable)
for object Yes Patient identifier (NHS number)
owner object Yes Responsible organization (provider)
basedOn array No Optional reference to care pathway
code object Yes Codes and text for task type classification (Consumer API)
reasonCode object Yes Codes and text for task type classification (Producer API)
reasonReference object Yes Reference to Questionnaire or BookingInvitation

Modified Fields

  • status: Changed from ["not-started", "in-progress", "completed", "cancelled"] to FHIR-compliant ["requested", "rejected", "cancelled", "in-progress", "completed"]
  • description: Enhanced with clearer guidance for both questionnaires and invites
  • extension: Streamlined to include Client ID and Treatment Function (for PIFU only)

Task Type Classification

Consumer API: Using code to Distinguish Task Types

The Consumer API uses the code field with an enum of specific task types for semantic clarity:

For Questionnaires:

code:
  coding:
    - system: "https://fhir.nhs.uk/CodeSystem/Task-Type"
      code: "pifu-triage"  # or pre-appointment-questionnaire, post-appointment-questionnaire, etc.
      display: "PIFU Triage Questionnaire"
  text: "Patient Initiated Follow-Up Questionnaire"

For Appointment Booking Invites:

code:
  coding:
    - system: "https://fhir.nhs.uk/CodeSystem/Task-Type"
      code: "appointment-booking-invite"
      display: "Appointment Booking Invitation"
  text: "Invitation to book an appointment"

Producer API: Using reasonCode to Distinguish Task Types

The Producer API uses the reasonCode field (system: Extension-Questionnaire-Type) for task type classification:

For Questionnaires:

reasonCode:
  coding:
    - system: "https://fhir.nhs.uk/CodeSystem/Task-Type"
      code: "pifu-triage"  # or other questionnaire codes
      display: "PIFU Triage Questionnaire"
  text: "Patient Initiated Follow-Up Questionnaire"

For Appointment Booking Invites:

reasonCode:
  coding:
    - system: "https://fhir.nhs.uk/CodeSystem/Task-Type"
      code: "appointment-booking-invite"
      display: "Appointment Booking Invitation"
  text: "Invitation to book an appointment"

Backwards Compatibility

Questionnaire Resource Preserved

  • The existing Questionnaire resource remains unchanged
  • Current consumers can continue using the Questionnaire resource without modification
  • No breaking changes to the Questionnaire schema

Migration Path

  1. Phase 1 (Current): Both Task and Questionnaire resources available
  2. Phase 2 (Future): Clients should migrate to using Task for new questionnaire implementations
  3. Phase 3 (Future): Questionnaire resource may be deprecated (with advance notice)

Use Cases

For NHS App and Consumer Applications (Consumer API):

  • Retrieve aggregated tasks across multiple Portal systems
  • Display unified task interface to patient
  • Use standardized enum-based task type codes
  • Leverage Client ID extension to identify Portal source

For Portal/Provider Systems (Producer API):

  • Implement Portal-specific appointment and document APIs
  • Return tasks in Portal-native format with reasonCode
  • Support appointment booking invitations and questionnaires
  • Implement treatment function extensions for PIFU

Data Models

Appointment Booking Invite (Task) - Producer API

id: ad8baee0-f2b2-4258-ad25-a8de19c32c14
status: requested
intent: plan
description: Book your Dermatology appointment
authored: '2026-07-16T09:00:00+00:00'
code:
  coding:
    - system: "https://fhir.nhs.uk/CodeSystem/Task-Type"
      code: "appointment-booking-invite"
      display: "Appointment Booking Invitation"
  text: "Invitation to book an appointment"
reasonReference:
  type: Task
  reference: "https://my.portal.com/BookingInvitation/ad8baee0-f2b2-4258-ad25-a8de19c32c14"
for:
  type: Patient
  identifier:
    system: "https://fhir.nhs.uk/Id/nhs-number"
    value: "9000000002"
owner:
  type: Organization
  identifier:
    system: "https://fhir.nhs.uk/Id/ods-organization-code"
    value: "RXP"
  display: "COUNTY DURHAM AND DARLINGTON NHS FOUNDATION TRUST"
restriction:
  period:
    end: '2026-08-16T23:59:59+00:00'

Questionnaire (Task) - Producer API

id: c21417eb-ffef-4a9e-b367-ebd8b8c29e7c
status: requested
intent: plan
description: Dermatology PIFU follow-up questionnaire
authored: '2025-06-20T18:00:00+00:00'
reasonCode:
  coding:
    - system: "https://fhir.nhs.uk/StructureDefinition/Extension-Questionnaire-Type"
      code: "pifu-triage"
      display: "PIFU Triage Questionnaire"
  text: "Patient Initiated Follow-Up Questionnaire"
reasonReference:
  type: Questionnaire
  reference: "https://my.portal.com/Questionnaire/c21417eb-ffef-4a9e-b367-ebd8b8c29e7c"
extension:
  - url: "https://fhir.nhs.uk/StructureDefinition/Extension-Task-TreatmentFunction"
    valueCoding:
      system: "https://fhir.nhs.uk/CodeSystem/Specialty-1"
      code: "330"
      display: "Dermatology"

Appointment Booking Invite (Task) - Consumer API

id: ad8baee0-f2b2-4258-ad25-a8de19c32c14
status: requested
intent: plan
description: Book your Dermatology appointment
authoredOn: '2026-07-16T09:00:00.000Z'
code:
  coding:
    - system: "https://fhir.nhs.uk/CodeSystem/Task-Type"
      code: "appointment-booking-invite"
      display: "Appointment Booking Invitation"
  text: "Invitation to book an appointment"
reasonReference:
  type: Task
  reference: "https://my.portal.com/BookingInvitation/ad8baee0-f2b2-4258-ad25-a8de19c32c14"
for:
  type: Patient
  identifier:
    system: "https://fhir.nhs.uk/Id/nhs-number"
    value: "9000000002"
owner:
  type: Organization
  identifier:
    system: "https://fhir.nhs.uk/Id/ods-organization-code"
    value: "RXP"
  display: "COUNTY DURHAM AND DARLINGTON NHS FOUNDATION TRUST"
restriction:
  repetitions: 1
  period:
    start: '2026-07-16T09:00:00.000Z'
    end: '2026-08-16T23:59:59.000Z'

Questionnaire (Task) - Consumer API

id: c21417eb-ffef-4a9e-b367-ebd8b8c29e7c
status: requested
intent: plan
description: Dermatology PIFU follow-up questionnaire
authoredOn: '2025-06-20T18:00:00.000Z'
code:
  coding:
    - system: "https://fhir.nhs.uk/CodeSystem/Task-Type"
      code: "pifu-triage"
      display: "PIFU Triage Questionnaire"
  text: "Patient Initiated Follow-Up Questionnaire"
reasonReference:
  type: Task
  reference: "https://my.portal.com/Questionnaire/c21417eb-ffef-4a9e-b367-ebd8b8c29e7c"
extension:
  - url: "https://fhir.nhs.uk/StructureDefinition/Extension-Client-id"
    valueCode: "myportal-01"
  - url: "https://fhir.nhs.uk/StructureDefinition/Extension-Task-TreatmentFunction"
    valueCoding:
      system: "https://fhir.nhs.uk/CodeSystem/Specialty-1"
      code: "330"
      display: "Dermatology"

Implementation Notes

For Consumer API Users

  • No immediate changes required if using Questionnaire resource
  • Optional migration: Adopt Task resource for future questionnaire implementations
  • New integrations: Use Task resource for all task types

For Portal Providers (Producer API)

  • Already implemented: Producer spec Task resource remains unchanged
  • Consistency: Consumer spec now aligns with Producer spec
  • Contract testing: Ensure portal systems work with both old Questionnaire and new Task patterns during transition

For the Aggregator Service

  • Data mapping: When aggregating from Portals (Producer API), transform incoming Task data from Producer format (reasonCode) to Consumer format (code) before returning in Consumer API responses
  • Field normalization: Map Producer's reasonCode to Consumer's code to maintain consistent Consumer API contracts
  • Gradual rollout: Transition consumers to Task resource over time while maintaining Questionnaire resource support
  • Validation: Ensure both Questionnaire and Task resource patterns are properly validated in API responses

Status Values Mapping

The new Task resource uses FHIR R4 compliant status values:

Old (Questionnaire) New (Task) Meaning
not-started requested Task available but not yet started by patient
in-progress in-progress Task started by patient
completed completed Task finished by patient
cancelled cancelled Task cancelled by system or patient
(new) rejected Patient explicitly declined/rejected task

Extension Framework

The Consumer API supports extensions to provide additional metadata:

  1. Client ID (optional)

    • Unique identifier for the upstream Portal system
    • System: https://fhir.nhs.uk/StructureDefinition/Extension-Client-id
    • Example value: "myportal-01"
  2. Treatment Function (conditional)

    • For PIFU questionnaires and questionnaires linked to specific specialties
    • System: https://fhir.nhs.uk/StructureDefinition/Extension-Task-TreatmentFunction
    • Required for PIFU questionnaires

The Producer API includes similar extensions:

  1. Treatment Function (conditional)
    • For PIFU questionnaires only
    • System: https://fhir.nhs.uk/StructureDefinition/Extension-Task-TreatmentFunction

Questions & Clarifications

Q: When will the Questionnaire resource be deprecated?
A: No immediate deprecation. The Questionnaire resource will remain supported during a transition period (to be determined). We'll provide advance notice before any deprecation.

Q: Do I need to update my system immediately?
A: No. Existing implementations using Questionnaire continue to work. Adopt Task resource for new implementations or when ready to migrate.

Q: How do I distinguish between task types?
A:

  • Consumer API: Use the code.coding.code field with values like "pifu-triage", "appointment-booking-invite", "pre-appointment-questionnaire", etc. All codes use system https://fhir.nhs.uk/CodeSystem/Task-Type.
  • Producer API: Use the reasonCode.coding.code field. The system is https://fhir.nhs.uk/StructureDefinition/Extension-Questionnaire-Type.

Q: What about linked appointments?
A: Use the focus field to reference an Appointment this task relates to:

  • For questionnaires before appointment: focus may be empty (appointment doesn't exist yet)
  • For questionnaires linked to appointments: focus.reference points to the related appointment
  • For appointment booking invites: focus is not required since the appointment doesn't exist until the patient completes the booking

Q: Can I store custom data in Task?
A: Yes, use extensions (array) to add custom fields following FHIR extension patterns.

@edwardbowyer-nhs edwardbowyer-nhs changed the title DRAFT - WPP-11130 - Proposed changes to API specs for Invite to Book DRAFT - SPEC CHANGE - WPP-11130 - Proposed changes to API specs for Invite to Book Jul 20, 2026
@RavenDuffyNHS

Copy link
Copy Markdown

Just want to check this has been aligned with kevin/sachit?

@edwardbowyer-nhs

Copy link
Copy Markdown
Contributor

Just want to check this has been aligned with kevin/sachit?

The design has been run through with Sachit yes, we collaborated on that, but not this specific spec change. Reaching out to David Rabbich in Sachit and Kevin's absence.

@NHSDigital NHSDigital deleted a comment from github-actions Bot Jul 21, 2026
@NHSDigital NHSDigital deleted a comment from github-actions Bot Jul 21, 2026
@NHSDigital NHSDigital deleted a comment from github-actions Bot Jul 21, 2026
@NHSDigital NHSDigital deleted a comment from github-actions Bot Jul 21, 2026
@RavenDuffyNHS

Copy link
Copy Markdown

Just want to check this has been aligned with kevin/sachit?

The design has been run through with Sachit yes, we collaborated on that, but not this specific spec change. Reaching out to David Rabbich in Sachit and Kevin's absence.

Definitely think this will be a positive change as the line between tasks and questionnaires is currently quite blurry.

@NHSDigital NHSDigital deleted a comment from github-actions Bot Jul 21, 2026
@NHSDigital NHSDigital deleted a comment from github-actions Bot Jul 21, 2026
@NHSDigital NHSDigital deleted a comment from github-actions Bot Jul 21, 2026
@NHSDigital NHSDigital deleted a comment from github-actions Bot Jul 21, 2026
@NHSDigital NHSDigital deleted a comment from github-actions Bot Jul 21, 2026
@NHSDigital NHSDigital deleted a comment from github-actions Bot Jul 21, 2026
@github-actions

Copy link
Copy Markdown

API Spec HTML Docs

Built from commit 73cf431view workflow run

Download HTML API Specs: api-specs-html-docs-73cf431.zip

@github-actions

Copy link
Copy Markdown

API Spec HTML Docs

Built from commit 6f93dffview workflow run

Download HTML API Specs: api-specs-html-docs-6f93dff.zip

@github-actions

Copy link
Copy Markdown

API Spec HTML Docs

Built from commit 582522cview workflow run

Download HTML API Specs: api-specs-html-docs-582522c.zip

@github-actions

Copy link
Copy Markdown

API Spec HTML Docs

Built from commit c4d2826view workflow run

Download HTML API Specs: api-specs-html-docs-c4d2826.zip

description: Resource type being referenced.
type: string
enum:
- Task

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The schema currently restricts reasonReference.type to Task, but examples reference Questionnaire and BookingInvitation URLs. Could we align schema and examples so referenced resource type and reference targets are consistent?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will be removing from Consumer spec as replaced by Task.Input. The Producer will support Task and Questionnaire , I believe all those examples are correct

type:
type: string
description: Questionnaire FHIR Resource
description: The type of task, used to differentiate behaviour in the Aggregator. Must be either `BookingInvitation` for Invite to Book tasks, or `Questionnaire` for questionnaire completion tasks.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a mismatch between description and enum here: description mentions BookingInvitation for invites, while enum allows Questionnaire and Task. Could we align these so allowed values are unambiguous?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good spot updated thanks

@@ -1063,8 +1065,8 @@ components:
- for
- authored

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consumer Task now uses authoredOn, while Producer still uses authored. Is this divergence intentional, or should Producer also move to authoredOn for cross-spec alignment?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirming the difference is intentional, as the Producer spec is currently in use by the PEPs for Questionnaire flow, we are unable to alter it at this time to maintain compatibility. However as we're adding to the Consumer spec, we are aligning strongly with FHIR standards.

- authored
- reasonReference
- owner
- reasonCode

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consumer Task now classifies task type in code. Producer still carries task-type semantics in reasonCode for questionnaire flow. Can we confirm if this difference is intentional or align both specs to the same model?

@edwardbowyer-nhs edwardbowyer-nhs Aug 17, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirming the difference is intentional, as the Producer spec is currently in use by the PEPs for Questionnaire flow, we are unable to alter it at this time to maintain compatibility. However as we're adding to the Consumer spec, we are aligning strongly with FHIR standards.

@@ -1063,8 +1065,8 @@ components:
- for
- authored
- reasonReference

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we confirm reasonReference semantics are aligned between producer and consumer? Current shape/typing appears to differ, which may cause mapping ambiguity for Invite-to-Book vs Questionnaire tasks.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reasonReference is now being removed from Consumer spec to use Task.Input to purvey URL

@KazeemHamzat

Copy link
Copy Markdown

Under

Invite to Book - Task Resource Alignment Summary

Overview

To support the Invite to Book changes, the design has been made to uplift the existing Task resource to support both Invitations to Book and Questionnaires, along with being extensible for further use cases.

The Consumer API Task resource and Producer API Task resource have been aligned to support multiple use cases (questionnaires, appointment booking invites, and future task types) while maintaining backwards compatibility with the existing Questionnaire resource. However, there are intentional differences in field naming between the two APIs:

  • Consumer API uses code field for task type classification
  • Producer API uses reasonCode field for task type classification

This aligns the Consumer API spec more closely with FHIR standards.

Why This Change?

Previous Implementation

  • Questionnaire-centric: The Consumer Task resource was essentially a copy of the Questionnaire resource with additional fields for appointment booking invites
  • Limited extensibility: The kind enum was rigid and required updates for each new task type
  • Misaligned with Producer spec: The Consumer spec Task didn't follow the producer-side FHIR Task pattern
  • Redundancy: Similar fields and logic across Questionnaire and Task resources

New Implementation

  • Generic task framework: Task resource can represent any patient action (questionnaires, booking invites, etc.)
  • FHIR R4 aligned: Follows standard FHIR Task structure with fields like status, intent, reasonCode, reasonReference
  • Producer-spec aligned: Matches the Producer API standards for consistency across the aggregator ecosystem
  • Future-proof: Extensible via reasonCode and extensions for new task types
  • Cleaner architecture: Single generic Task resource instead of type-specific variants

Key Changes

Removed Fields

  • kind → Replaced by code in Consumer API, reasonCode in Producer API (FHIR standard, provides more semantic meaning)
  • scheduledPeriod → Replaced by restriction.period (FHIR standard)
  • performer → Replaced by owner (FHIR standard terminology)

Added Fields

Field Type Required Purpose
id string Yes Globally unique identifier for the task
identifier object No System-specific identifier (portal database ID)
intent string Yes Always "plan" - indicates task intent
authored date-time Yes When task became available to patient
lastModified date-time No When task was last modified by patient
restriction.period object No Start/end dates for task deadline
focus object No Reference to linked Appointment (if applicable)
for object Yes Patient identifier (NHS number)
owner object Yes Responsible organization (provider)
basedOn array No Optional reference to care pathway
code object Yes Codes and text for task type classification (Consumer API)
reasonCode object Yes Codes and text for task type classification (Producer API)
reasonReference object Yes Reference to Questionnaire or BookingInvitation

Modified Fields

  • status: Changed from ["not-started", "in-progress", "completed", "cancelled"] to FHIR-compliant ["requested", "rejected", "cancelled", "in-progress", "completed"]
  • description: Enhanced with clearer guidance for both questionnaires and invites
  • extension: Streamlined to include Client ID and Treatment Function (for PIFU only)

Task Type Classification

Consumer API: Using code to Distinguish Task Types

The Consumer API uses the code field with an enum of specific task types for semantic clarity:

For Questionnaires:

code:
  coding:
    - system: "https://fhir.nhs.uk/CodeSystem/Task-Type"
      code: "pifu-triage"  # or pre-appointment-questionnaire, post-appointment-questionnaire, etc.
      display: "PIFU Triage Questionnaire"
  text: "Patient Initiated Follow-Up Questionnaire"

For Appointment Booking Invites:

code:
  coding:
    - system: "https://fhir.nhs.uk/CodeSystem/Task-Type"
      code: "appointment-booking-invite"
      display: "Appointment Booking Invitation"
  text: "Invitation to book an appointment"

Producer API: Using reasonCode to Distinguish Task Types

The Producer API uses the reasonCode field (system: Extension-Questionnaire-Type) for task type classification:

For Questionnaires:

reasonCode:
  coding:
    - system: "https://fhir.nhs.uk/CodeSystem/Task-Type"
      code: "pifu-triage"  # or other questionnaire codes
      display: "PIFU Triage Questionnaire"
  text: "Patient Initiated Follow-Up Questionnaire"

For Appointment Booking Invites:

reasonCode:
  coding:
    - system: "https://fhir.nhs.uk/CodeSystem/Task-Type"
      code: "appointment-booking-invite"
      display: "Appointment Booking Invitation"
  text: "Invitation to book an appointment"

Backwards Compatibility

Questionnaire Resource Preserved

  • The existing Questionnaire resource remains unchanged
  • Current consumers can continue using the Questionnaire resource without modification
  • No breaking changes to the Questionnaire schema

Migration Path

  1. Phase 1 (Current): Both Task and Questionnaire resources available
  2. Phase 2 (Future): Clients should migrate to using Task for new questionnaire implementations
  3. Phase 3 (Future): Questionnaire resource may be deprecated (with advance notice)

Use Cases

For NHS App and Consumer Applications (Consumer API):

  • Retrieve aggregated tasks across multiple Portal systems
  • Display unified task interface to patient
  • Use standardized enum-based task type codes
  • Leverage Client ID extension to identify Portal source

For Portal/Provider Systems (Producer API):

  • Implement Portal-specific appointment and document APIs
  • Return tasks in Portal-native format with reasonCode
  • Support appointment booking invitations and questionnaires
  • Implement treatment function extensions for PIFU

Data Models

Appointment Booking Invite (Task)

id: ad8baee0-f2b2-4258-ad25-a8de19c32c14
status: requested
intent: plan
description: Book your Dermatology appointment
authoredOn: '2026-07-16T09:00:00.000Z'
code:
  coding:
    - system: "https://fhir.nhs.uk/CodeSystem/Task-Type"
      code: "appointment-booking-invite"
      display: "Appointment Booking Invitation"
  text: "Invitation to book an appointment"
reasonReference:
  type: Task
  reference: "https://my.portal.com/BookingInvitation/ad8baee0-f2b2-4258-ad25-a8de19c32c14"
for:
  type: Patient
  identifier:
    system: "https://fhir.nhs.uk/Id/nhs-number"
    value: "9000000002"
owner:
  type: Organization
  identifier:
    system: "https://fhir.nhs.uk/Id/ods-organization-code"
    value: "RXP"
  display: "COUNTY DURHAM AND DARLINGTON NHS FOUNDATION TRUST"
restriction:
  repetitions: 1
  period:
    start: '2026-07-16T09:00:00.000Z'
    end: '2026-08-16T23:59:59.000Z'

Questionnaire (Task) - Consumer API

id: c21417eb-ffef-4a9e-b367-ebd8b8c29e7c
status: requested
intent: plan
description: Dermatology PIFU follow-up questionnaire
authoredOn: '2025-06-20T18:00:00.000Z'
code:
  coding:
    - system: "https://fhir.nhs.uk/CodeSystem/Task-Type"
      code: "pifu-triage"
      display: "PIFU Triage Questionnaire"
  text: "Patient Initiated Follow-Up Questionnaire"
reasonReference:
  type: Task
  reference: "https://my.portal.com/Questionnaire/c21417eb-ffef-4a9e-b367-ebd8b8c29e7c"
extension:
  - url: "https://fhir.nhs.uk/StructureDefinition/Extension-Client-id"
    valueCode: "myportal-01"
  - url: "https://fhir.nhs.uk/StructureDefinition/Extension-Task-TreatmentFunction"
    valueCoding:
      system: "https://fhir.nhs.uk/CodeSystem/Specialty-1"
      code: "330"
      display: "Dermatology"

Appointment Booking Invite (Task) - Producer API

id: ad8baee0-f2b2-4258-ad25-a8de19c32c14
status: requested
intent: plan
description: Book your Dermatology appointment
authored: '2026-07-16T09:00:00+00:00'
code:
  coding:
    - system: "https://fhir.nhs.uk/CodeSystem/Task-Type"
      code: "appointment-booking-invite"
      display: "Appointment Booking Invitation"
  text: "Invitation to book an appointment"
reasonReference:
  type: Task
  reference: "https://my.portal.com/BookingInvitation/ad8baee0-f2b2-4258-ad25-a8de19c32c14"
for:
  type: Patient
  identifier:
    system: "https://fhir.nhs.uk/Id/nhs-number"
    value: "9000000002"
owner:
  type: Organization
  identifier:
    system: "https://fhir.nhs.uk/Id/ods-organization-code"
    value: "RXP"
  display: "COUNTY DURHAM AND DARLINGTON NHS FOUNDATION TRUST"
restriction:
  period:
    end: '2026-08-16T23:59:59+00:00'

Questionnaire (Task) - Producer API

id: c21417eb-ffef-4a9e-b367-ebd8b8c29e7c
status: requested
intent: plan
description: Dermatology PIFU follow-up questionnaire
authored: '2025-06-20T18:00:00+00:00'
reasonCode:
  coding:
    - system: "https://fhir.nhs.uk/StructureDefinition/Extension-Questionnaire-Type"
      code: "pifu-triage"
      display: "PIFU Triage Questionnaire"
  text: "Patient Initiated Follow-Up Questionnaire"
reasonReference:
  type: Questionnaire
  reference: "https://my.portal.com/Questionnaire/c21417eb-ffef-4a9e-b367-ebd8b8c29e7c"
extension:
  - url: "https://fhir.nhs.uk/StructureDefinition/Extension-Task-TreatmentFunction"
    valueCoding:
      system: "https://fhir.nhs.uk/CodeSystem/Specialty-1"
      code: "330"
      display: "Dermatology"

Implementation Notes

For Consumer API Users

  • No immediate changes required if using Questionnaire resource
  • Optional migration: Adopt Task resource for future questionnaire implementations
  • New integrations: Use Task resource for all task types

For Portal Providers (Producer API)

  • Already implemented: Producer spec Task resource remains unchanged
  • Consistency: Consumer spec now aligns with Producer spec
  • Contract testing: Ensure portal systems work with both old Questionnaire and new Task patterns during transition

For the Aggregator Service

  • Data mapping: When aggregating from Portals (Producer API), transform incoming Task data from Producer format (reasonCode) to Consumer format (code) before returning in Consumer API responses
  • Field normalization: Map Producer's reasonCode to Consumer's code to maintain consistent Consumer API contracts
  • Gradual rollout: Transition consumers to Task resource over time while maintaining Questionnaire resource support
  • Validation: Ensure both Questionnaire and Task resource patterns are properly validated in API responses

Status Values Mapping

The new Task resource uses FHIR R4 compliant status values:

Old (Questionnaire) New (Task) Meaning
not-started requested Task available but not yet started by patient
in-progress in-progress Task started by patient
completed completed Task finished by patient
cancelled cancelled Task cancelled by system or patient
(new) rejected Patient explicitly declined/rejected task

Extension Framework

The Consumer API supports extensions to provide additional metadata:

  1. Client ID (optional)

    • Unique identifier for the upstream Portal system
    • System: https://fhir.nhs.uk/StructureDefinition/Extension-Client-id
    • Example value: "myportal-01"
  2. Treatment Function (conditional)

    • For PIFU questionnaires and questionnaires linked to specific specialties
    • System: https://fhir.nhs.uk/StructureDefinition/Extension-Task-TreatmentFunction
    • Required for PIFU questionnaires

The Producer API includes similar extensions:

  1. Treatment Function (conditional)

    • For PIFU questionnaires only
    • System: https://fhir.nhs.uk/StructureDefinition/Extension-Task-TreatmentFunction

Questions & Clarifications

Q: When will the Questionnaire resource be deprecated? A: No immediate deprecation. The Questionnaire resource will remain supported during a transition period (to be determined). We'll provide advance notice before any deprecation.

Q: Do I need to update my system immediately? A: No. Existing implementations using Questionnaire continue to work. Adopt Task resource for new implementations or when ready to migrate.

Q: How do I distinguish between task types? A:

  • Consumer API: Use the code.coding.code field with values like "pifu-triage", "appointment-booking-invite", "pre-appointment-questionnaire", etc. All codes use system https://fhir.nhs.uk/CodeSystem/Task-Type.
  • Producer API: Use the reasonCode.coding.code field. The system is https://fhir.nhs.uk/StructureDefinition/Extension-Questionnaire-Type.

Q: What about linked appointments? A: Use the focus field to reference an Appointment this task relates to:

  • For questionnaires before appointment: focus may be empty (appointment doesn't exist yet)
  • For questionnaires linked to appointments: focus.reference points to the related appointment
  • For appointment booking invites: focus is not required since the appointment doesn't exist until the patient completes the booking

Q: Can I store custom data in Task? A: Yes, use extensions (array) to add custom fields following FHIR extension patterns.

Under the section for Extension Framework.
Could you update the following as follows. Change System to URL. System applies to vocabulary while URL applies to StructuredDefinition. In this context, Extension element.

1* System: https://fhir.nhs.uk/StructureDefinition/Extension-Client-id to

    • URL: https://fhir.nhs.uk/StructureDefinition/Extension-Client-id

2 * URL: https://fhir.nhs.uk/StructureDefinition/Extension-Task-TreatmentFunction

    • For PIFU questionnaires only
  • URL: https://fhir.nhs.uk/StructureDefinition/Extension-Task-TreatmentFunction

4.reasonCode:

coding:
- system: "https://fhir.nhs.uk/CodeSystem/Questionnaire-Type"
code: "pifu-triage"
display: "PIFU Triage Questionnaire"
text: "Patient Initiated Follow-Up Questionnaire"

5* Producer API: Use the reasonCode.coding.code field. The system is https://fhir.nhs.uk/CodeSystem/Questionnaire-Type.

However, there is also a need to clarify how this CodeSystem 'https://fhir.nhs.uk/CodeSystem/Questionnaire-Type' relates to PIFU option in 'https://fhir.nhs.uk/England/CodeSystem/Task-Type'

  • pre-appointment-questionnaire
    - post-appointment-questionnaire
    - general-update-questionnaire
    - pifu-triage
    - appointment-booking-invite

@github-actions

Copy link
Copy Markdown

API Spec HTML Docs

Built from commit 5f940c4view workflow run

Download HTML API Specs: api-specs-html-docs-5f940c4.zip

to align more closely with FHIR standard

and more clearly indicate the URL needed to perform the task in the portal system
to replace reasonReference with input
@github-actions

Copy link
Copy Markdown

API Spec HTML Docs

Built from commit f78fa18view workflow run

Download HTML API Specs: api-specs-html-docs-f78fa18.zip

@github-actions

Copy link
Copy Markdown

API Spec HTML Docs

Built from commit e15ce17view workflow run

Download HTML API Specs: api-specs-html-docs-e15ce17.zip

system: "https://fhir.nhs.uk/Id/ods-organization-code"
value: "RFF"
display: "Barnsley Hospital NHS Foundation Trust"
code:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reasonCode is listed as required at the Task level, but this example doesn't include it (only code is present). Since reasonCode was kept for questionnaire backward-compatibility, can we make it conditionally required (e.g. only when the task is a questionnaire type) rather than universally required? Otherwise this example fails schema validation.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yes of course, thank you, I've removed reasonCode from required at task level.

…hub.com:NHSDigital/patient-care-aggregator-api into apm-000-WPP-11130-proposed-task-changes-for-ItB
@github-actions

Copy link
Copy Markdown

❌ Branch Name Validation Failed

Branch format is invalid.

Expected format: <prefix>/<JIRA-key>-<kebab-description>

Ensure JIRA ticket key is included. Allowed prefixes: feat, feature, chore, spike, hotfix, bugfix, release, revert

apm-000-WPP-11130-proposed-task-changes-for-ItB

@github-actions

Copy link
Copy Markdown

API Spec HTML Docs

Built from commit 5e80716view workflow run

Download HTML API Specs: api-specs-html-docs-5e80716.zip

@nebh2 nebh2 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM from SCS

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants