Skip to content

[HOTE-559] feat: View negative results page#173

Merged
cptiv2020 merged 89 commits intomainfrom
feature/hote-559/results-view
Mar 3, 2026
Merged

[HOTE-559] feat: View negative results page#173
cptiv2020 merged 89 commits intomainfrom
feature/hote-559/results-view

Conversation

@cptiv2020
Copy link
Copy Markdown
Contributor

@cptiv2020 cptiv2020 commented Mar 2, 2026

Description

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

re-opened with new branch naming: #149

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.

cptiv2020 and others added 30 commits February 12, 2026 12:06
Signed-off-by: lewisbirks <lewis.birks1@nhs.net>
Signed-off-by: lewisbirks <lewis.birks1@nhs.net>
…est-consumer-for-get-order

# Conflicts:
#	database/03-seed-hometest-data.sql
# Conflicts:
#	lambdas/src/get-results-lambda/init.ts
#	local-environment/infra/main.tf
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Mar 2, 2026

Lambdas Coverage Report

Lines Statements Branches Functions
Coverage: 91%
91.3% (21/23) 100% (0/0) 87.5% (7/8)

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Mar 2, 2026

UI Coverage Report

Lines Statements Branches Functions
Coverage: 92%
92.96% (3225/3469) 86.96% (327/376) 78.72% (111/141)

Copilot AI review requested due to automatic review settings March 3, 2026 09:09
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 support for viewing a negative HIV self-test result page in the UI, backed by a new results API/service layer, plus supporting content and end-to-end accessibility coverage.

Changes:

  • Adds a new /orders/:orderId/results route and UI components for the negative result view (with redirects back to tracking when results aren’t available/eligible).
  • Introduces new UI query/service utilities for fetching results and centralises GUID validation.
  • Updates lambda DB queries and local CORS config to support results retrieval, plus adds unit/UI/a11y tests.

Reviewed changes

Copilot reviewed 48 out of 51 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
ui/src/routes/TestResultsPage.tsx New results route logic (order/result gating + redirect).
ui/src/routes/OrderTrackingPage.tsx Switches to shared GUID util + order status query hook + page content hook.
ui/src/lib/utils/guid.ts Extracted GUID/UUID validation helper.
ui/src/lib/utils/fhir-utils.ts Adds FHIR Observation “normal” interpretation helper.
ui/src/lib/utils/fhir-constants.ts Adds constants for Observation interpretation system/code.
ui/src/lib/services/test-results-service.ts New UI service to call /results and map Observation → TestResult.
ui/src/lib/services/supplier-service.ts Centralised supplier link metadata lookup.
ui/src/lib/queries/test-results-query.ts React Query hook for test results.
ui/src/lib/queries/query-keys.ts Shared query key names for React Query.
ui/src/lib/queries/order-status-query.ts React Query hook wrapper for order status.
ui/src/lib/models/test-result.ts New UI model for test results.
ui/src/lib/models/route-paths.ts Adds TestResultsPage route path.
ui/src/components/test-results/NegativeTestResult.tsx Negative result page content component.
ui/src/components/test-results/MoreOptionsAndInformation.tsx Supplementary “more options” section component.
ui/src/components/test-results/MedicalAbbreviationsHelp.tsx Help link section component.
ui/src/components/order-status/statuses/ReadyStatus.tsx Replaces placeholder link with router Link to results page.
ui/src/components/order-status/statuses/HelpLinks.tsx Uses supplier service for contact link instead of #.
ui/src/components/order-status/OrderStatusHeader.tsx Allows caller-provided heading text.
ui/src/components/order-status/OrderStatusContent.tsx Passes orderId into ReadyStatus.
ui/src/components/order-status/OrderStatus.tsx Passes fixed heading string to OrderStatusHeader.
ui/src/app.tsx Registers new results route under guarded app routes.
ui/src/tests/routes/TestResultsPage.test.tsx Unit tests for results route behaviour and redirects.
ui/src/tests/lib/utils/fhir-utils.test.ts Unit tests for FHIR utility helpers.
ui/src/tests/lib/services/test-results-service.test.ts Unit tests for results service request/response mapping.
ui/src/tests/lib/services/supplier-service.test.ts Unit tests for supplier link lookup.
ui/src/tests/lib/services/la-lookup-service.test.ts Minor test import/style adjustments.
ui/src/tests/components/order-status/OrderStatusHeader.test.tsx Updates tests for new heading prop.
ui/src/tests/components/NegativeTestResult.test.tsx Unit tests for negative result component rendering.
ui/src/tests/components/MoreOptionsAndInformation.test.tsx Unit tests for more-options component.
ui/src/tests/components/MedicalAbbreviationsHelp.test.tsx Unit tests for abbreviations help component.
ui/package.json Bumps @types/node patch version.
ui/package-lock.json Lockfile updates for @types/node + dependencies.
ui/hooks/useContent.ts Adds test-results page content typing + overload.
ui/content/schema.ts Adds TestResultsContent type (but currently has duplicate interface declarations).
ui/content/index.ts Exports TestResultsContent type.
ui/content/content.json Adds test-results page content (contains a title typo).
ui/content/ContentValidator.ts Requires test-results page content key.
tests/tests/accessibility/NegativeResultsTest.spec.ts New Playwright accessibility spec for negative results page.
tests/page-objects/NegativeResultPage.ts New page object for results navigation/assertions.
tests/db/TestResultDbClient.ts Import tidy-up.
tests/db/TestOrderDbClient.ts Import order tidy-up.
tests/api/clients/HIVResultsApiResource.ts Import/order formatting tidy-up.
package-lock.json Root lockfile updates.
local-environment/infra/main.tf Adds CORS allowed headers including X-Correlation-ID.
lambdas/src/lib/db/test-result-db-client.ts Refactors ctor + changes SQL schema qualifiers (but JOIN condition is incorrect).
lambdas/src/lib/db/test-result-db-client.test.ts Updates expected SQL (currently matches the incorrect JOIN).
lambdas/src/lib/db/order-db-client.ts Refactors ctor + changes SQL schema qualifiers.
lambdas/src/lib/db/order-db-client.test.ts Updates expected SQL.
lambdas/src/get-results-lambda/init.test.ts Import reorder/cleanup.
lambdas/src/get-order-lambda/init.test.ts Import reorder/cleanup.
.gitignore Stops ignoring ui/src/components/test-results/ folder.
Files not reviewed (1)
  • ui/package-lock.json: Language not supported
Comments suppressed due to low confidence (1)

ui/content/schema.ts:364

  • OrderTrackingContent removal introduced duplicate type declarations later in this file: PrivacyPolicySubsection, PrivacyPolicySection, and HomeTestPrivacyPolicyContent are each declared twice, which will cause a TypeScript "Duplicate identifier" compile error. Remove the duplicate block and keep a single set of these interfaces.
export interface PrivacyPolicySubsection {
  heading?: string;
  paragraphs?: string[];
  list?: string[];
}

export interface PrivacyPolicySection {
  id: string;
  heading: string;
  paragraphs: string[];
  subsections?: PrivacyPolicySubsection[];
}

export interface HomeTestPrivacyPolicyContent {
  title: string;
  introduction: string[];
  sections: PrivacyPolicySection[];
}

export interface PrivacyPolicySubsection {
  heading?: string;
  paragraphs?: string[];
  list?: string[];
}

export interface PrivacyPolicySection {
  id: string;
  heading: string;
  paragraphs: string[];
  subsections?: PrivacyPolicySubsection[];
}

export interface HomeTestPrivacyPolicyContent {
  title: string;
  introduction: string[];
  sections: PrivacyPolicySection[];
}

Comment thread ui/content/content.json Outdated
Comment thread lambdas/src/lib/db/test-result-db-client.ts Outdated
Comment thread tests/tests/accessibility/NegativeResultsTest.spec.ts Outdated
Comment thread lambdas/src/lib/db/test-result-db-client.test.ts Outdated
Copilot AI review requested due to automatic review settings March 3, 2026 09:30
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 49 out of 52 changed files in this pull request and generated no new comments.

Files not reviewed (1)
  • ui/package-lock.json: Language not supported
Comments suppressed due to low confidence (2)

ui/content/schema.ts:364

  • PrivacyPolicySubsection, PrivacyPolicySection, and HomeTestPrivacyPolicyContent are declared twice in this file (around lines 328–364), which will cause TypeScript duplicate identifier errors. Remove the duplicate set of interface declarations and keep a single canonical definition.
export interface PrivacyPolicySubsection {
  heading?: string;
  paragraphs?: string[];
  list?: string[];
}

export interface PrivacyPolicySection {
  id: string;
  heading: string;
  paragraphs: string[];
  subsections?: PrivacyPolicySubsection[];
}

export interface HomeTestPrivacyPolicyContent {
  title: string;
  introduction: string[];
  sections: PrivacyPolicySection[];
}

export interface PrivacyPolicySubsection {
  heading?: string;
  paragraphs?: string[];
  list?: string[];
}

export interface PrivacyPolicySection {
  id: string;
  heading: string;
  paragraphs: string[];
  subsections?: PrivacyPolicySubsection[];
}

export interface HomeTestPrivacyPolicyContent {
  title: string;
  introduction: string[];
  sections: PrivacyPolicySection[];
}

ui/src/routes/OrderTrackingPage.tsx:28

  • useOrderStatusQuery returns data as undefined while the query is pending, so if (!order) will render the “order not found” error during loading (and also hides query errors). Destructure and handle isPending/error (e.g., return a loading state or null while pending, and throw/render an error for error) before treating order === null as the not-found case.

Comment thread tests/tests/accessibility/NegativeResultsTest.spec.ts Outdated
Copilot AI review requested due to automatic review settings March 3, 2026 10:03
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 49 out of 51 changed files in this pull request and generated 6 comments.

Files not reviewed (1)
  • ui/package-lock.json: Language not supported
Comments suppressed due to low confidence (1)

ui/src/routes/OrderTrackingPage.tsx:28

  • useOrderStatusQuery returns data as undefined while the request is pending, but this component treats any falsy order as “not found”. That means the “We could not find this order.” alert will render during the initial load (and also for network/errors), which is misleading and can cause a visible flash before the real order renders. Handle isPending/isLoading (and error) from the query separately (e.g., return null/spinner while pending, and throw/show a distinct error state when error is set).

Comment thread ui/src/lib/queries/test-results-query.ts
Comment thread ui/src/lib/services/test-results-service.ts
Comment thread ui/src/lib/services/supplier-service.ts
Comment thread tests/tests/accessibility/NegativeResultsTest.spec.ts
Comment thread tests/page-objects/NegativeResultPage.ts Outdated
Comment thread ui/src/lib/queries/order-status-query.ts
@cptiv2020 cptiv2020 merged commit 4b9930e into main Mar 3, 2026
21 checks passed
@cptiv2020 cptiv2020 deleted the feature/hote-559/results-view branch March 3, 2026 10:23
billwirz1 added a commit that referenced this pull request Mar 3, 2026
* feat(HOTE-611): init implementation of new lambda

* feat(HOTE-611): pull status description

* feat: set-up-goose-for-db-migrations

* chore: set-up-scripts-and-readme-for-migrations

* fix: missing-newlines

* fix: missing-newlines

* feat: add-seed-data-with-goose

* fix: eof-errors

* fix: remove-trailing-whitespace

* chore: add-eof-to-pre-commit

* chore: remove-keywords-from-schemas

* feat: reafactor code

* fix: swap-static-and-seed-data-from-migrations

* feat: added unit tests

* chore: line endings

Signed-off-by: lewisbirks <lewis.birks1@nhs.net>

* fix: broken-foreign-key

* fix: comment-out-delete-sql

* feat: refactoring and tests

* fix: correct seed script

Signed-off-by: lewisbirks <lewis.birks1@nhs.net>

* feat: update local terraform with new lambda

* fix: seed-data-errors

* fix: remove-unused-pre-commit-hook

* fix: fix after tests

* fix: added cors configuration and replaced hardcoded patient data

* fix: correct frommating

* fix: fix ui test

* fix: fix lint error

* fix: corrections after review

* feat(HOTE-521): initial implementation of lambda

* fix: updated redeployment trigger

* fix: updated trigger

* feat: implemented proper sql query and observation builder, added tests

* fix: use proper zip for lambda

* fix: return the test type from database

* fix: getting test code from database

* feat: initial implementation of request to supplier api for results

* fix: updated to use only supplier api for result

* feat(HOTE-521): refactor code to separate classes

* fix: get reduced information from db for result

* fix: changes after review

* feat: introduced x-correlation-id for results endpoint

* chore: update packages

* Add api tes for get results

* feat: added initial page

* fix: set the proper fields for auth context

* feat: implement initial version of test result query

* feat: implemented logic to show the results page only for negative result

* fix: push to ensure the tests uses proper file

* fix: bump package

* fix: fix gitignore for missing files

* fix: make props readonly

* feat: introduced supplier links service

* fix: refactor test

* fix: follow new database connection approach

* fix: update tags to align with prototype

* Result page accessibility test

* add negative result to fixtures

* fix: fixes after review

* removed testedUser checks

* fix: formatting

---------

Signed-off-by: lewisbirks <lewis.birks1@nhs.net>
Co-authored-by: billwirz1 <bill.wirz1@nhs.net>
Co-authored-by: lewisbirks <lewis.birks1@nhs.net>
Co-authored-by: Masha-kainos <256341953+Masha-kainos@users.noreply.github.com>
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.

8 participants