Skip to content

Fix: [AEA-6327] - missing prescriptions fix#1860

Open
jonathanwelch1-nhs wants to merge 14 commits intomainfrom
aea-6327-missing-prescriptions
Open

Fix: [AEA-6327] - missing prescriptions fix#1860
jonathanwelch1-nhs wants to merge 14 commits intomainfrom
aea-6327-missing-prescriptions

Conversation

@jonathanwelch1-nhs
Copy link
Contributor

@jonathanwelch1-nhs jonathanwelch1-nhs commented Mar 3, 2026

Summary

https://nhsd-jira.digital.nhs.uk/browse/AEA-6327
https://nhsd-jira.digital.nhs.uk/browse/AEA-6276

  • Routine Change

Details

Fixed the state that got corrupted when you searched for a prescription and clicked back.
Previously, clicking on View a Prescription altered the saved state which got loaded and rendered on the page. It is now not corrupted and displays the original full search
Also inserts issueNumber=0 which equals to falsy, and so isnt chained on to any endpoint calls when you click back so is more hardy

@github-actions
Copy link
Contributor

github-actions bot commented Mar 3, 2026

This PR is linked to a ticket in an NHS Digital JIRA Project. Here's a handy link to the ticket:

AEA-6327

@jonathanwelch1-nhs jonathanwelch1-nhs changed the title Fix: [AEA-6210] - missing prescriptions fix Fix: [AEA-6327] - missing prescriptions fix Mar 3, 2026
@sonarqubecloud
Copy link

searchParams.append("prescriptionId", searchContext.prescriptionId)
} else {
// Check original parameters first, then fall back to current search context
const originalSearchParams = navigationContext.getOriginalSearchParameters()
Copy link
Contributor

@Orkastrated Orkastrated Mar 19, 2026

Choose a reason for hiding this comment

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

I think all this can be further simplified into a fairly concise switch statement and generic function, something like:

useEffect(() => {
  const runSearch = async () => {
    setLoading(true)

    // Use searchType from SearchProvider to determine which parameter to search with
    const searchParams = new URLSearchParams()
    // Check original parameters first, then fall back to current search context
    const originalSearchParams = navigationContext.getOriginalSearchParameters()

	const handleSearchParams = (searchType) => {
		const searchParam = originalSearchParams[searchType] || searchContext[searchType]
		if (!searchParam){
			// invalid redirect?
			navigate(FRONTEND_PATHS.SEARCH_BY_PRESCRIPTION_ID)
		}
		searchParams.append(searchType, param)
	}

	switch(searchContext.searchType) {
		case "nhs":
			handleSearchParams("nhsNumber")
		case: "prescriptionId":
			handleSearchParams("prescriptionId")
		case: "basicDetails":
			handleSearchParams("nhsNumber")
		default:
			// invalid redirec?
			navigate(FRONTEND_PATHS.SEARCH_BY_PRESCRIPTION_ID)
	}

	try{
		...
	}
	// and the rest
}

Copy link
Contributor

Choose a reason for hiding this comment

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

And if you do this i'd probably look to make the searchType nhsNumber rather than just nhs, that way you could probably tweak the switch statement to:

switch(searchContext.searchType) {
		case "nhs":
		case: "prescriptionId":
			handleSearchParams(searchType)
		case: "basicDetails":
			handleSearchParams("nhsNumber")
		default:
			// invalid redirec?
			navigate(FRONTEND_PATHS.SEARCH_BY_PRESCRIPTION_ID)
	}

Copy link
Contributor

Choose a reason for hiding this comment

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

Also those searchTypes should probably be an enum

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.

3 participants