Functional Weave
Code in Rust

health.nhs-number-format@1.0.0

README.md

1,766 bytes · view raw

# health.nhs-number-format

An NHS number in the 3-3-4 display format, `943 476 5919`, after a full
modulus 11 check by `validation.nhs-number` (`validateNhsNumber`, ^2.0.0).

NHS numbers are stored as ten digits and conventionally shown to people as
three groups separated by spaces, which makes a transcription error easier to spot on a
screen, a letter or a wristband. Input may already be spaced or hyphenated;
the digits are what count.

## Why an invalid number is an error

A formatter that spaces out whatever it is given turns a mistyped number into
something that looks official. So the number is checked first, and an
invalid one raises `not a valid NHS number (<reason>)`, where the reason is
`validation.nhs-number`'s: `empty`, `bad-character`, `bad-length`,
`bad-check-digit` or `placeholder` (0000000000 and the like, which pass the
arithmetic). The message deliberately does not repeat the number: it is a
patient identifier, and error messages end up in logs.

A valid check digit means the number is well formed, not that it was issued
or belongs to this patient; that needs a Personal Demographics Service trace.

## Level

The catalogue lists this at level 0, but it requires `validation.nhs-number`,
which is level 1, and a capability may not depend on a higher level; so it is
level 1.

## Source

NHS Data Model and Dictionary, *NHS NUMBER*: ten numeric digits, the tenth a
check digit validated by the modulus 11 algorithm
(https://www.datadictionary.nhs.uk/attributes/nhs_number.html). The check
itself, and the 3-3-4 `formatted` form returned here, are
`validation.nhs-number`'s; see its README. The Data Dictionary entry does not
itself define the display grouping; 3-3-4 is the grouping NHS systems and
correspondence conventionally use.