Skip to content

T-SQL Function to check if the provided NHS Number is valid

Notifications You must be signed in to change notification settings

Rich-In-SQL/NHSNumberCheck

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

Repository files navigation

NHS Number Validation Function

This function takes a UK NHS Number as an input variable and checks to see if that NHS Number is or isn't valid.

This uses the Modulus 11 algorithm which is mandatory for checking the NHS Number.

https://www.datadictionary.nhs.uk/attributes/nhs_number.html

Why did you create this?

After a discussion with one of our clients, we got to talking about NHS Numbers and how they are validated. We did some research and it got us interested so we decided to create a T-SQL function that can validate an NHS Number automatically.

Functions in views

Remember, don't use scalar functions in views, performance will tank, this function is a decent proof of concept as to how you can validate the NHS Number in your own projects if required.

Using The Function

It is possible to get dummy NHS Numbers from here which you can use for testing this function.

Once you have added the NHS Number to your database of choice, you can use it like this

Manually passing a value

SELECT [dbo].[fnNHSValidation_svf]('6043153327')

Passing a value from an existing table

SELECT [dbo].[fnNHSValidation_svf](NHSNumber) FROM Patients

About

T-SQL Function to check if the provided NHS Number is valid

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages