stdnum.gb.nhs

NHS (United Kingdom National Health Service patient identifier).

The NHS number is used by the NHS (National Health Service) and its partners to uniquely identify patients. The number is used in England, Wales and the Isle of Man. The number is assigned at birth and consists of 10 digits where the final digit is a check digit.

More information:

>>> validate('943-476-5870')
'9434765870'
>>> validate('9434765871')  # invalid check digit
Traceback (most recent call last):
    ...
InvalidChecksum: ...
>>> format('9434765870')
'943 476 5870'
stdnum.gb.nhs.checksum(number)

Calculate the checksum. The checksum is only used for the 9 digits of the number and the result can either be 0 or 42.

stdnum.gb.nhs.compact(number)

Convert the number to the minimal representation. This strips the number of any valid separators and removes surrounding whitespace.

stdnum.gb.nhs.format(number, separator=' ')

Reformat the number to the standard presentation format.

stdnum.gb.nhs.is_valid(number)

Check if the number is valid.

stdnum.gb.nhs.validate(number)

Check if the number is valid. This checks the length and check digit.