![]() ![]() Typically, letters than can easily be confused with numbers (B, I, O, Q, S, and Z) are omitted. These algorithms not only allow letters and numbers to be used throughout the identifier, but also allow the check "digit" to be a letter. The idgen module supports additional algorithms, including Mod25 and Mod30 algorithms. The Luhn CheckDigit Validator uses this variation to allow for letters, whereas the Luhn Mod-10 Check-Digit Validator uses the standard Luhn Algorithm using only numbers 0-9. To keep life simple, we convert identifiers to uppercase and remove any spaces before applying the algorithm. The letters "A" through "Z" are values 65 to 90 in the ASCII table (and become values 17 to 42 in our algorithm after subtracting 48). Subtracting 48 lets the characters "0" to "9" assume the values 0 to 9 we'd expect. We subtract 48 because the characters "0" through "9" are assigned values 48 to 57 in the ASCII table. To handle alphanumeric digits (numbers and letters), we actually use the ASCII value (the computer's internal code) for each character and subtract 48 to derive the "digit" used in the Luhn algorithm. Adding a 2-3 letter suffix to the identifer was our solution. In our case (Regenstrief with the AMPATH Medical Record System), we were forced to come up with a simple method for generating identifiers in disparate, disconnected location without collision (giving out the same number twice). In fact, the potential for mistaking numbers and letters likely increases the chance for errors. This allows for an identifier like "139MT" that the original Luhn algorithm cannot handle (it's limited to numeric digits only).Īllowing letters- even limited to capital letters-does not increase the accuracy of data entry. In this variation, we allow for letters as well as numbers in the identifier (i.e., alphanumeric identifiers). We have borrowed the variation on the Luhn algorithm used by Regenstrief Institute, Inc. Our variation on the Luhn algorithm Allowing for Letters For a sum of '14', the check digit is '6' since '20' is the next number divisible by ten. So the answer is '1 + 8 + 3 + 2 = 14' and the check digit is the amount needed to reach a number divisible by ten. Now sum all of the digits (note '18' is two digits, '1' and '8'). ![]() Work right-to-left, using "139" and doubling every other digit. ![]()
0 Comments
Leave a Reply. |