Skip to main content

A small package to perform checksum validation on NHS numbers.

Project description


lifecycle: experimental

The nhssums package provides functions for working with NHS number checksums.

NHS Number Overview

NHS numbers are issued to patients of the NHS in the UK.

The number consists of 9 digits and a single digit checksum.

For more information, please see the NHS number Wikipedia article on the subject.


To install the published version of the package from PyPI:

python3 -m pip install nhssums


Use is_valid() to iterate over a list of numbers:

>>> nhssums = [1234567881, 1234567806, 123456876, 1234512343]
>>> nhssums.is_valid(nhs_numbers)
[True, True, False, True]

To check if the checksum is valid for a single number, use is_number_valid():

>>> import nhssums
>>> nhssums.is_number_valid(1234567881)
>>> nhssums.is_number_valid(1234567882)

Finally, generate_checksum() will return a valid checksum, for a given input number. It can also return the full number (input + checksum) if required:

>>> nhssums.generate_checksum(123451234)
>>> nhssums.generate_checksum(123451234, full_output = True)


This package is released under an MIT license.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nhssums-0.1.2.tar.gz (3.2 kB view hashes)

Uploaded Source

Built Distribution

nhssums-0.1.2-py3-none-any.whl (4.3 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page