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

2 thoughts on “NHS Number Validation

  1. Pingback: Peter Fisher « Blog News « NHSNumberValidator is being used by the University of Nottingham

  2. Great code thanks Pete. One little error in the php version – if the input fails the input validation valid gets set to false, then back to true. Since the default is true I’ve removed that line.

Leave a Reply

Your email address will not be published. Required fields are marked *

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=""> <s> <strike> <strong>