-
Notifications
You must be signed in to change notification settings - Fork 215
Added support for AIC codes #193
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Thanks for your pull request. Since you also seem to be the original author of pyAIC are you OK with licensing this under the LGPL so it can be included in I'll have a look. There will probably be some adaptations to follow the rest of the coding style (e.g. taking advantage of the |
Also, is it true that the BASE10 representation is the canonical form and the BASE32 version is just for encoding into a bar code? The reason I'm asking is that most other From there we could either have conversion functions to and from the BASE32 form or automatically convert the BASE32 form to the BASE10 representation. |
Hi @arthurdejong , I will start refactoring code and tests to better comply with the existing interface. I will take a look at stdnum.ultils, stdnum.luhn and stdnum.exceptions to improve Regarding the relationship between BASE10 and Base32, BASE10 should be the canonical form, while BASE32 is for barcodes, as you wrote. The official paper linked above defines a checksum only for BASE10 representation, so conversion function are needed. |
Apart from the functions you mentioned no others are really required. I don't think a Since BASE10 should be the normal form, I would say the module could implement Btw, the check digit calculation can be rewritten into something like: def calc_check_digit(number):
"""Calculate the check digit for the BASE10 AIC code."""
weights = (1, 2, 1, 2, 1, 2, 1, 2)
return str(sum((x // 10) + (x % 10)
for x in (w * int(n) for w, n in zip(weights, number))) % 10) Thanks. |
Updated functions and tests. |
I've merged your PR with some modifications as 8433821. Thanks for providing the code! |
AIC codes are used to identify drugs allowed to be sold in Italy.
Codes are assigned by AIFA, or "Agenzia Italiana del Farmaco" (Italian Medicines Agency), the italian authority responsible for drugs regulation in Italy.
The italian Government defined how these codes are structured in an official bill available here, valid since the 30th of may 2014.