pharma_datamatrix
=================
Pharma Datamatrix is a python library that allow users to pass the string
produced by the 2D barcode scanners and parse the string into GTIN, PPN,
EXPIRY, SERIAL, BATCH and NHRN.
Installing
----------
See INSTALL
Package Contents
----------------
pharma_datamatrix/
pharma_datamatrix sources.
datamatrix.py: Primary function that checks the barcode format
and inturn calls relevant parsing logic function.
gs1_gtin.py: Parse the GS1 GTIN barcode string and validate GTIN &
Expiry.
ifa_ppn.py: Parse the IFA PPN barcode string (MACRO 06 & MACRO 05) and
validate PPN & Expiry.
expiry_date_validation.py: This files contains the logic that validates
the Expiry date. This file checks if the
YYMMDD contains valid digits. Ex: MM to be
between 01 & 12. And if the expiry date
greater than the date of the scan: i.e. not
is valid past date.
gs1_gtin_validation.py: This file contains the logic that validates the
GS1 - GTIN.
ifa_ppn_validation.py: This file contains the logic to validate IFA PPN
format.
Usage
-----
The function datamatrix(barcode: str, separator):
The first parameter 'barcode' is of 'string' type and its mandatory.
The string should contain the <GS> seperator as per GS1 guidelines.
The second parameter 'separator' is the char that scanner read from <GS>,
by default is 29.
Initial Import:
from pharma_datamatrix.datamatrix import read_datamatrix
The next examples us the default separator <GS> with code 29:
Example 1: Usage with validation (valid barcode)
read_datamatrix('01085860077038511724123110HB5R21587E4QA11R')
Output: {
'NHRN': None,
'GTIN': '08586007703851',
'EXPIRY': '241231',
'BATCH': 'HB5R1',
'SERIAL': '21587E4QA11R'
}
Example 2: Usage without validation (Invalid barcode)
read_datamatrix('085860077038511724113110HB5R21587E4QA11R')
Output: {'ERROR': 'INVALID BARCODE'}
Example 3: Usage with validation (valid barcode format but Invalid expiry date
(31 Nov 24))
read_datamatrix('01085860077038511724113110HB5R21587E4QA11R')
Output: {'ERROR': 'INVALID EXPIRY DATE'}
Example 4: Usage with validation (valid barcode format but Invalid GTIN)
read_datamatrix('01083860077038511724113110HB5R21587E4QA11R')
Output: {'ERROR': 'INVALID GTIN'}
This example use a different separator with code 199 (Ç):
Example 5: Usage with validation (valid barcode)
read_datamatrix('01085860077038511724123110HB5RÇ21587E4QA11RÇ7127166559',
199)
Output: {
'GTIN': '08586007703851',
'EXPIRY': '241231',
'BATCH': 'HB5R1',
'SERIAL': '21587E4QA11R'
'NHRN': 7166559,
}
Support
-------
License
-------
See LICENSE
Copyright
---------
See project files for the complete list of Copyright owners.
Forked from
-----------
Github link: https://github.com/PinchofLogic/pharma_datamatrix