Tools for Working with NHS Number Checksums

Provides functions for working with NHS number checksums. The UK's National Health Service issues NHS numbers to all users of its services and this package implements functions for verifying that the numbers are valid according to the checksum scheme the NHS use. Numbers can be validated and checksums created.


nhsnumber

CRAN status R-CMD-check codecov Lifecycle: stable

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.

Installation

You can install the released version of nhsnumber from CRAN with:

install.packages("nhsnumber")

You can install the development version of nhsnumber from GitHub with:

devtools::install_github("sellorm/nhsnumber")

Example

The 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)

Which returns:

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.

nhsnumber::get_checksum(123456788)

which returns:

1

or with the full output:

nhsnumber::get_checksum(123456788, full_output = TRUE)

Which returns:

1234567881

Some number combinations are invalid and these will throw an error, for example:

nhsnumber::get_checksum(123456789)

Which results in this:

Error in nhsnumber::get_checksum(123456789) : Input sequence is invalid
           Checksum was 10 which is not permissable

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("nhsnumber")

0.1.2 by Mark Sellors, 5 years ago


https://github.com/sellorm/nhsnumber


Report a bug at https://github.com/sellorm/nhsnumber/issues


Browse source code at https://github.com/cran/nhsnumber


Authors: Mark Sellors [aut, cre, cph]


Documentation:   PDF Manual  


MIT + file LICENSE license


Suggests testthat


See at CRAN