Skip to content

Commit

Permalink
Fix: [AEA-4256] - Scottish and NI NHS numbers not being rejected (#551)
Browse files Browse the repository at this point in the history
## Summary

- Routine Change

### Details

Fix for a bug where the additional validation wasn't included in the
list of validations being applied. Addition of range for test NHS
numbers.
  • Loading branch information
originalphil authored Jul 18, 2024
1 parent d277c9d commit c7970aa
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
4 changes: 3 additions & 1 deletion packages/updatePrescriptionStatus/src/validation/content.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ export function nhsNumberRange(task: Task): string | undefined {
const validRanges: Array<Range> = [
{low: 3_113_000_000, high: 3_200_000_000},
{low: 4_000_000_000, high: 4_999_999_999},
{low: 6_000_000_000, high: 7_999_999_999}
{low: 6_000_000_000, high: 7_999_999_999},
{low: 9_000_000_000, high: 9_999_999_999}
]

const nhsNumber = Number(task.for!.identifier!.value)
Expand Down Expand Up @@ -167,6 +168,7 @@ export function taskContent(task: Task): Array<string> {
businessStatus,
lastModified,
nhsNumber,
nhsNumberRange,
prescriptionID,
resourceType,
taskStatusAgainstBusinessStatus,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,10 @@ describe("Unit test for validateContent", () => {
task.focus!.identifier!.system = "invalidLineItemIdCodeSystem"
const entry: BundleEntry = {fullUrl: FULL_URL_0, resource: task}

const expectedOutcome = {valid: false, issues: "NHS number is invalid. Invalid CodeSystem(s) - LineItemID."}
const expectedOutcome = {
valid: false,
issues: "NHS number is invalid. NHS number is not in a known, valid range. Invalid CodeSystem(s) - LineItemID."
}

const actual: ValidationOutcome = validateContent(entry)

Expand All @@ -83,7 +86,11 @@ describe("Unit test for taskContent", () => {
task.for!.identifier!.value = "invalidNhsNumber"
task.focus!.identifier!.system = "invalidLineItemIdCodeSystem"

const expectedOutcome = ["NHS number is invalid.", "Invalid CodeSystem(s) - LineItemID."]
const expectedOutcome = [
"NHS number is invalid.",
"NHS number is not in a known, valid range.",
"Invalid CodeSystem(s) - LineItemID."
]

const actual: Array<string> = taskContent(task)

Expand Down Expand Up @@ -224,7 +231,16 @@ describe("Unit tests for validation of NHS number range", () => {
scenarioDescription: "When NHS number is in the Northern Irish range, should return expected issue."
},
{
nhsNumbers: ["3113000000", "3200000000", "4000000000", "4999999999", "6000000000", "7999999999"],
nhsNumbers: [
"3113000000",
"3200000000",
"4000000000",
"4999999999",
"6000000000",
"7999999999",
"9000000000",
"9999999999"
],
expected: undefined,
scenarioDescription: "When NHS number is in the NHSE range."
}
Expand Down

0 comments on commit c7970aa

Please sign in to comment.