Skip to content

[HOTE-983] feat: Generate Notification: Order Dispatched#316

Open
cptiv2020 wants to merge 10 commits intomainfrom
feature/hote-983/generate-notify-for-order-dispatched
Open

[HOTE-983] feat: Generate Notification: Order Dispatched#316
cptiv2020 wants to merge 10 commits intomainfrom
feature/hote-983/generate-notify-for-order-dispatched

Conversation

@cptiv2020
Copy link
Copy Markdown
Contributor

@cptiv2020 cptiv2020 commented Apr 3, 2026

Description

https://nhsd-jira.digital.nhs.uk/browse/HOTE-983

Context

Type of changes

  • Refactoring (non-breaking change)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would change existing functionality)
  • Bug fix (non-breaking change which fixes an issue)

Checklist

  • I am familiar with the contributing guidelines
  • I have followed the code style of the project
  • I have added tests to cover my changes
  • I have updated the documentation accordingly
  • This PR is a result of pair or mob programming

Sensitive Information Declaration

To ensure the utmost confidentiality and protect your and others privacy, we kindly ask you to NOT including PII (Personal Identifiable Information) / PID (Personal Identifiable Data) or any other sensitive data in this PR (Pull Request) and the codebase changes. We will remove any PR that do contain any sensitive information. We really appreciate your cooperation in this matter.

  • I confirm that neither PII/PID nor sensitive data are included in this PR and the codebase changes.

Copilot AI review requested due to automatic review settings April 3, 2026 08:04
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 3, 2026

UI Coverage Report

Lines Statements Branches Functions
Coverage: 95%
95.5% (5585/5848) 87.28% (652/747) 87.5% (203/232)

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 3, 2026

Lambdas Coverage Report

Lines Statements Branches Functions
Coverage: 98%
98.36% (1382/1405) 92.09% (408/443) 96.46% (218/226)

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds “Order Dispatched” notification generation to the order-status ingestion flow, extending the lambdas package with new message-building and DB/audit utilities and wiring local infra env vars to support local execution.

Changes:

  • Enqueue a Notify message to SQS when an order receives its first DISPATCHED status, and write a notification audit entry.
  • Introduce NotifyEventCode.OrderDispatched plus supporting NotifyMessageBuilder, PatientDbClient, and NotificationAuditDbClient.
  • Update local Terraform to provide queue URL and base URL env vars to order-status-lambda.

Reviewed changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
local-environment/infra/main.tf Adds env vars for notify queue URL and home test base URL for local order-status lambda.
lambdas/src/order-status-lambda/notify-message-builder.ts Builds the ORDER_DISPATCHED notify payload (recipient lookup + personalisation).
lambdas/src/order-status-lambda/notify-message-builder.test.ts Unit tests for message construction, date formatting, and base URL normalisation.
lambdas/src/order-status-lambda/init.ts Wires new DB clients, SQS client, message builder, and env var retrieval into DI.
lambdas/src/order-status-lambda/init.test.ts Extends init wiring tests for the new dependencies/env vars.
lambdas/src/order-status-lambda/index.ts Sends dispatched notification on first DISPATCHED status; inserts notification audit entry.
lambdas/src/order-status-lambda/index.test.ts Adds handler tests covering notification send / suppression behavior.
lambdas/src/lib/types/notify-message.ts Adds OrderDispatched event code to the notify message model.
lambdas/src/lib/db/patient-db-client.ts Adds DB lookup for notify recipient data (NHS number + DOB) by patient UID.
lambdas/src/lib/db/patient-db-client.test.ts Unit tests for patient recipient lookup and missing-record behavior.
lambdas/src/lib/db/order-status-db.ts Adds isFirstStatusOccurrence() helper used to gate first-time DISPATCHED notifications.
lambdas/src/lib/db/order-status-db.test.ts Adds tests for isFirstStatusOccurrence(); improves DBClient typing in test setup.
lambdas/src/lib/db/notification-audit-db-client.ts Adds insert helper for notification_audit table entries.
lambdas/src/lib/db/notification-audit-db-client.test.ts Unit tests for audit insert behavior and zero-row failure case.

Copilot AI review requested due to automatic review settings April 3, 2026 08:58
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 14 out of 14 changed files in this pull request and generated 5 comments.

…of github.com:NHSDigital/hometest-service into feature/hote-983/generate-notify-for-order-dispatched
Copilot AI review requested due to automatic review settings April 3, 2026 09:16
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 14 out of 14 changed files in this pull request and generated 5 comments.

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud bot commented Apr 3, 2026

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.

2 participants