patients-io / frameinventory

0 stars 0 forks source link

Handle Multiple Barcode Types #4

Closed michael-martin-al closed 6 years ago

michael-martin-al commented 6 years ago

Multiple barcode types on frames. The barcode reader can read the code but some are in GTIN 14 and some in GTIN 13. However the MIM system has them all as GTIN 13. There is an easy fix for this. When the file is parsed into the DB we need to create a GTIN 14 for all barcodes so when scanning we can check for both code types. The only difference is leading zeros. The GTIN 14 has one extra zero in the number. Example. GTIN 13 = 8053672557664, GTIN 14 = 08053672557664. The pattern is the same for GTIN 12, GTIN 8 expect more leading zeros are adding 2 and 6 respectively.

michael-martin-al commented 6 years ago

For now, we will attempt to match the barcode using a % wildcard match in Postgres. For example, upc LIKE '%8053672557664 which will match 08053672557664. I think this will address the problem in most cases, but there might be an edge case where two different UPCs share the same last 13 digits, but they're not the same product. Something like 8053672557664 and A8053672557664. If that happens, we'll have to work on our matching pattern a little more.