Functional Weave
Code in TypeScript

health.nhs-number-format@1.0.1

README.md

3,108 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.

## Before you rely on this

**Not professional advice.** This capability calculates health figures from published rules. It is a software component for developers, not medical advice. Rules change and every rate here has an effective date. Check that the dates cover your case. Verify results against the official sources listed above, and have a clinician review how you use it, before anyone relies on the output. Provided "as is" under its licence, without warranty.

**Not a medical device.** It is not intended to diagnose, treat or support clinical decisions about any individual. Anyone building it into clinical software is responsible for that software's regulatory status, and must validate it under their own clinical governance.

**Unreviewed.** This capability's implementations agree in every language and pass its published test vectors, which were worked out from the official sources cited. But no qualified clinician has yet checked those vectors, or confirmed that the capability covers the cases it claims. Treat it as a draft. Do not use it for real people, money or decisions without your own expert review. Once a qualified reviewer signs off, this notice is replaced with their name, qualification and the date. Each new version needs fresh sign-off.

1.0.1 marks it unreviewed. The code and the tests are unchanged.