Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: [AEA-4509] - Removes NHS Number Range Validation from CPSU #883

Merged
merged 5 commits into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
6 changes: 0 additions & 6 deletions packages/cpsuLambda/src/schema/format_1/validator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,5 @@ export const validator: Validator<eventType, requestType> = (event, logger: Logg
return Err(wrap_with_status(202, {})("Message Ignored"))
}

const nhsNumber = parseInt(requestBody.nHSCHI)
if (nhsNumber >= 101000000 && nhsNumber < 3113000000) {
logger.warn(`Message with nHSCHI number '${nhsNumber}' Ignored`)
return Err(wrap_with_status(202, {})("Message Ignored"))
}

return Ok(requestBody)
}
8 changes: 3 additions & 5 deletions packages/cpsuLambda/tests/testHandler.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,20 +125,18 @@ describe("format_1 handler", () => {
expect(logger_warn).toHaveBeenCalledWith("Message of type 'NOTPrescriptionStatusChanged' Ignored")
})

test("Messages with non NHSEngland number are ignored", async () => {
test("Messages with non NHSEngland number are accepted", async () => {
const body = format_1_request()
body.nHSCHI = "1996344668"

const {handler, logger_warn} = mockedWarnHandler()
const {handler} = mockedWarnHandler()
const event = {
headers: {},
body
}

const response = await handler(event as format_1.eventType, dummyContext)
expect(response.statusCode).toEqual(202)
expect(JSON.parse(response.body)).toEqual("Message Ignored")
expect(logger_warn).toHaveBeenCalledWith("Message with nHSCHI number '1996344668' Ignored")
expect(response.statusCode).toEqual(200)
})

// PSU will validate the NHS number so pass it through and let the PSU provide the error message
Expand Down