# pfwd/NHSNumber-Validation

Example scripts that validate a NHS number written in various langauges
C# PHP
Switch branches/tags
Nothing to show
Fetching latest commitâ€¦
Cannot retrieve the latest commit at this time.

### NHS Number Validation Examples

The NHS Number is 10 digits long. The last digit is the "Check Number" or "Check Digit ". This is used to validate the full NHS Number. A calculation is made on the first 9 digits and its sum is compared against the check digit to see if the NHS Number is correct.

## The calculation

1. Multiply each of the first nine digits by a defined weight. The weight is shown below:

1 - 10

2 - 9

3 - 8

4 - 7

5 - 6

6 - 5

7 - 4

8 - 3

9 - 2

For example if the 2nd digit is 3 then its 3 x 8. If fourth digit is 7 then its 7 x 4

1. Get the sum of the 9 multiplications.

2. Divide this sum by 11 and get the remainder

3. Subtract 11 from the remainder to get the total

4. If the total is 11 then the identifier is 0, otherwise the identifier is the total

5. If the identifier is 10 then the NHS Number is wrong

6. If the identifier equals the check number then the NHS number is correct