| calculate_check_digit | R Documentation |
This function calculates the check digit for a given ID based on the DIN ISO 7064, Mod 11,10 algorithm.
calculate_check_digit(patid)
patid |
A numeric or character string representing the ID. It should be either 9 or 10 digits long. |
The function processes the input 'patid' as follows: - If the input has 10 digits and does not start with '0', it is assumed to be a patient ID with a check digit. The check digit is removed. - If the input has 9 digits, a leading '0' is added. - If the input has 10 digits and starts with '0', it is already in the expected format. - If the input does not match these cases, an error message is returned.
The check digit is calculated using the ISO 7064, Mod 11,10 method.
An integer representing the computed check digit (0-9). Returns 'NA' if the input is invalid.
calculate_check_digit("100000138") # Returns check digit (1) for this ID
calculate_check_digit(123456789) # Works with numeric input as well (6)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.