NHS Number Validation


The NHSNumberValidator is an open source project that validates a given number against the rules used to identify valid NHS numbers.

What is a NHS number

A NHS Number is a unique ten digit number which is given to all registered patients in England and Wales. It is used to identify a patent and their records. The NHS Number is used by local GP’s and Hospitals. Usually the NHS Number can be found on letters sent from your doctor.

How the NHS number is built

The NHS number is ten digits in length. It is shown on letters in the following format xxx-xxx-xxxx.  The first nine digits are the identifier and the tenth number is the check digit which is  used to check the validity of the identifier. The check digit is calculated using the Modules 11 algorithm.

How the NHSNumberValidator checks the validity of the supplied number

The NHSNumberValidator uses the standard method of validating the a NHS number.  Please see the page xxx for the validation method

Who is using the NHSNumberValidator

The University of Nottingham  has created an open source  program called OpenPseudonymiser.  The program incorporates the C# flavor of  the NHSNumberValidator to validate NHS numbers.  It is  used within (but not limited too) NHS clinical computer systems to pseudonymise datasets by creating a digest of one or more columns of a CSV file. More information can be found on the OpenPseudonymiser website

Can I use the NHSNumberValidator

Yes, its open source and the code is public on github.  All I ask is a link back to my blog and accreditation. Please DM via twitter for more info.

The source code

Currently there are two flavors  of the NHSNumberValidator that can be used. One is written in PHP and the other is in C#. Both work in a similar fashion and give the same results. They are just written in different languages.

The source code is on GitHub and can be found at https://github.com/pfwd/NHSNumber-Validation

More Infomation

NHS.uk – NHS Number

Good Books on Software Testing

Facebook Twitter Digg Stumbleupon Email

  One Response to “NHS Number Validation”

 Leave a Reply



You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>