chi_pad: Add a leading zero to nine-digit CHI numbers

View source: R/chi_pad.R

chi_padR Documentation

Add a leading zero to nine-digit CHI numbers

Description

chi_pad takes a nine-digit CHI number with character class and prefixes it with a zero. Any values provided which are not a string comprised of nine numeric digits remain unchanged.

Usage

chi_pad(x)

Arguments

x

a CHI number or a vector of CHI numbers with character class.

Details

The Community Health Index (CHI) is a register of all patients in NHS Scotland. A CHI number is a unique, ten-digit identifier assigned to each patient on the index.

The first six digits of a CHI number are a patient's date of birth in DD/MM/YY format. The first digit of a CHI number must, therefore, be 3 or less. Depending on the source, CHI numbers are sometimes missing a leading zero.

While a CHI number is made up exclusively of numeric digits, it cannot be stored with numeric class in R. This is because leading zeros in numeric values are silently dropped, a practice not exclusive to R. For this reason, chi_pad accepts input values of character class only, and returns values of the same class. It does not assess the validity of a CHI number - please see chi_check() for that.

Value

The original character vector with CHI numbers padded if applicable.

Examples

chi_pad(c("101011237", "101201234"))

Health-SocialCare-Scotland/phsmethods documentation built on Jan. 28, 2024, 3:18 a.m.