https://github.com/sellorm/nhsnumber
An R package to work with NHS numbers and their checksums
https://github.com/sellorm/nhsnumber
nhs r r-pkg
Last synced: over 1 year ago
JSON representation
An R package to work with NHS numbers and their checksums
- Host: GitHub
- URL: https://github.com/sellorm/nhsnumber
- Owner: sellorm
- License: other
- Created: 2019-09-11T18:25:23.000Z (almost 7 years ago)
- Default Branch: main
- Last Pushed: 2021-12-29T13:10:16.000Z (over 4 years ago)
- Last Synced: 2024-10-25T00:34:17.528Z (over 1 year ago)
- Topics: nhs, r, r-pkg
- Language: R
- Homepage: https://nhsnumber.sellorm.com/
- Size: 47.9 KB
- Stars: 10
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# nhsnumber
[](https://CRAN.R-project.org/package=nhsnumber)
[](https://github.com/sellorm/nhsnumber/actions?query=workflow%3AR-CMD-check)
[](https://app.codecov.io/gh/sellorm/nhsnumber)
[](https://lifecycle.r-lib.org/articles/stages.html#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](https://en.wikipedia.org/wiki/NHS_number) on the subject.
## Installation
You can install the released version of nhsnumber from [CRAN](https://cran.r-project.org/package=nhsnumber) with:
``` r
install.packages("nhsnumber")
```
You can install the development version of nhsnumber from [GitHub](https://github.com/sellorm/nhsnumber) with:
``` r
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.
``` r
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.
``` r
nhsnumber::get_checksum(123456788)
```
which returns:
```
1
```
or with the full output:
``` r
nhsnumber::get_checksum(123456788, full_output = TRUE)
```
Which returns:
```
1234567881
```
Some number combinations are invalid and these will throw an error, for example:
``` r
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
```