Fix: [AEA-6327] - missing prescriptions fix#1860
Open
jonathanwelch1-nhs wants to merge 14 commits intomainfrom
Open
Fix: [AEA-6327] - missing prescriptions fix#1860jonathanwelch1-nhs wants to merge 14 commits intomainfrom
jonathanwelch1-nhs wants to merge 14 commits intomainfrom
Conversation
Contributor
|
This PR is linked to a ticket in an NHS Digital JIRA Project. Here's a handy link to the ticket: AEA-6327 |
packages/cpt-ui/src/components/prescriptionList/PrescriptionsListTable.tsx
Outdated
Show resolved
Hide resolved
…into aea-6327-missing-prescriptions
|
Orkastrated
reviewed
Mar 19, 2026
| searchParams.append("prescriptionId", searchContext.prescriptionId) | ||
| } else { | ||
| // Check original parameters first, then fall back to current search context | ||
| const originalSearchParams = navigationContext.getOriginalSearchParameters() |
Contributor
There was a problem hiding this comment.
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
}
Contributor
There was a problem hiding this comment.
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)
}
Contributor
There was a problem hiding this comment.
Also those searchTypes should probably be an enum
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Summary
https://nhsd-jira.digital.nhs.uk/browse/AEA-6327
https://nhsd-jira.digital.nhs.uk/browse/AEA-6276
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