It should satisfy the below requirements
- must be unique
- not a sequence - so no-one can generate new ID based on knowledge of the existing one
- Medication request number is a reason for the pharmacist to ship the drugs to any person who knows the number
- should be easy to read and pass a number to other person via any channel: orally, phone, sms.
Solutions
Solution 1
ID with the below structure
XXX-1234-5678-9012-C
where
XXX - series, can be used to split ID's between the groups based on the way how it was generated.
initially we can should generate all the ids within the same series.
Options for the series:
- all the latin letters - 8000 combinations
- only some letters that looks the same in Cyrillic and Latin alphabet and can be entered via the phone keypad: A, E, H, K, M, P, T, X - 512 combinations
- numbers - 1000 combinations
It is proposed to go with option 2 with the possibility to extend to option 1 if needed in future
1234-5678-9012 - randomly generated numbers
Number of combinations - 1,000,000,000,000
Options for numbers:
- just random numbers
- random and some salt like timestamp
- hash on some personal data like birthday or phone number
It is proposed to start with option 2. And later we can change this decision and start generating new ID's in other manner using new series.
C - checksum to minimize the probability of human mistakes. Should be calculated using the Damn algorithm or Verhoeff algorithm.
There is no difference between these algorithms in terms of error detection. So we should chose the one based on what is easier to implement.
The proposed solution means that after new ID was generated we should check that it is unique in the DB. The probability of collisions is not low enough to avoid that.
Total number of possible combinations will be:
512,000,000,000,000
Probability of collisions: 0.1% probability in the range of around 3 millions.
Solution 2
The same as solution1, but
12E4-5A8-P01X-T3 - randomly generated numbers and letters A, E, H, K, M, P, T, X.
In this case:
Probability of collisions: 0.01% probability in the range of around 343 millions.
In this case we might not check if ID is unique.
But this number is not so convenient for human to work with.