Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,8 @@ describe("BasicDetailsSearchResultsPage", () => {
dobMonth: "01",
dobYear: "1990",
postcode: "SW1A 1AA",
nhsNumber: "9726919207"
nhsNumber: "9726919207",
searchType: "nhs"
})
})
})
Expand Down
4 changes: 4 additions & 0 deletions packages/cpt-ui/src/context/NavigationProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,10 @@ export const NavigationProvider: React.FC<NavigationProviderProps> = ({
!originalSearchParameters ||
originalSearchParameters.searchType !== searchType
) {
logger.info("Navigation: No relevant search parameters found", {
searchType,
originalSearchParameters
})
Comment on lines +163 to +166
Copy link

Copilot AI Mar 27, 2026

Choose a reason for hiding this comment

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

This log line includes originalSearchParameters, which can contain patient identifiers (e.g. NHS number, name, postcode). Logging these at info level risks leaking PII into browser logs and creates noisy telemetry since getRelevantSearchParameters is called frequently. Consider removing the parameters from the log (or redacting sensitive fields) and/or downgrading to debug/trace.

Copilot uses AI. Check for mistakes.
return {}
}

Expand Down
5 changes: 4 additions & 1 deletion packages/cpt-ui/src/pages/BasicDetailsSearchResultsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,12 @@ export default function SearchResultsPage() {
if (payload.length === 1) {
const relevantParams =
navigationContext.getRelevantSearchParameters("basicDetails")
// Set the search type before attempting search again
// As we'll now be using the nhs number search
searchContext.setAllSearchParameters({
...relevantParams,
nhsNumber: payload[0].nhsNumber
nhsNumber: payload[0].nhsNumber,
searchType: "nhs"
})
Comment on lines 152 to 161
Copy link

Copilot AI Mar 27, 2026

Choose a reason for hiding this comment

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

setAllSearchParameters overwrites searchType; this block correctly sets searchType: "nhs" for the single-result path, but the row-click path in the same page still calls setAllSearchParameters without searchType, which will clear it and can cause PrescriptionListPage to hit the default case and redirect to prescription-ID search. Consider also setting the appropriate searchType (and updating the related row-click/link/key navigation tests accordingly) so navigation is consistent for both single and multi-result flows.

Copilot uses AI. Check for mistakes.
navigate(FRONTEND_PATHS.PRESCRIPTION_LIST_CURRENT)
return
Expand Down
3 changes: 1 addition & 2 deletions packages/cpt-ui/src/pages/PrescriptionListPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,7 @@ export default function PrescriptionListPage() {
const hasAnyPrescriptionId = Boolean(originalSearchParams?.prescriptionId || searchContext.prescriptionId)
if (originalSearchParams &&
(originalSearchParams.firstName || originalSearchParams.lastName) &&
!hasAnyNhsNumber &&
!hasAnyPrescriptionId) {
(!hasAnyNhsNumber && !hasAnyPrescriptionId)) {
logger.info("Basic details present but no NHS number/ prescription ID - redirecting to prescription ID search")
navigate(FRONTEND_PATHS.SEARCH_BY_PRESCRIPTION_ID)
return
Expand Down
Loading