A vectorised function to convert a Scottish CHI number to date of birth in POSIXct date format. Note that this function does not always work as not all CHI numbers correspond accurately to date of birth, and any person born before 1920 will appear to be 100 years younger unless the optional cent parameter set to TRUE. Childen born in or after 2020 will appear 100 years older unless the optional paed parameter is set to TRUE. This function requires the stringr package.
vector of CHI numbers (as numeric or string)
Whether paediatric patient (TRUE/FALSE), either a vector or a single TRUE/FALSE for whole series
Whether born before 1920 (TRUE/FALSE), either a vector or a single TRUE/FALSE for whole series
The paed and cent parameters can either be provided as vectors for each case, for example in a series where there are patients with dates of birth in both the 1910s and 2010s, or alternatively can be set as a single TRUE or FALSE for the whole series.
a vector of POSIXct dates
1 2 3 4 5 6 7 8 9
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.