The goal of nhsnumber is to provide some simple functions for working with NHS numbers in R.
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.
You can install the released version of nhsnumber from Github with:
is_valid function takes a vector of NHS numbers and returns TRUE or FALSE depending on whether the checksum is successfully validated.
x <- c(9876543210, 1234567890, 1234567881) nhsnumber::is_valid(x)
TRUE FALSE TRUE
It's also possible to generate the checksums using the
get_checksum function. This function uses the 9 core digits and returns either the checksum on its own, or the full 10 digit number.
or with the full output:
nhsnumber::get_checksum(123456788, full_output = TRUE)
Some number combinations are invalid and these will throw an error, for example:
Which results in this:
Error in nhsnumber::get_checksum(123456789) : Input sequence is invalid Checksum was 10 which is not permissable