SStocta
GP surgeriesAesthetics clinicsPricingGuidesSecurityBook a demo

Guide

How to scan the 2D barcode on medicine packs to record batch and expiry

Use a 2D imaging scanner or a phone or tablet camera, with stock software that understands GS1 codes. The small square GS1 DataMatrix on many UK medicine packs holds the product code, expiry date, batch number and often a serial number, and GS1-aware software splits them into separate fields so nobody types them.

Not every pack has one, and since 1 January 2025 the 2D barcode is optional on UK packs. Keep a way to type the batch and expiry from the printed text.

Last reviewed 30 November 2026

Three things have to line up: the pack has a GS1 DataMatrix, the scanner can read 2D codes and passes on the separator character, and the software can split GS1 fields. If any one is missing, you fall back to typing.

What is in the code

GS1 codes use numbered Application Identifiers (AIs) to label each piece of data. These are the four you will see on medicine packs, as defined in the GS1 Application Identifier reference:

AIWhat it holdsFormat
(01)GTIN, the product code14 digits, fixed
(17)Expiry dateYYMMDD, 6 digits, fixed
(10)Batch or lot numberUp to 20 characters, variable
(21)Serial numberUp to 20 characters, variable

Because the batch and serial vary in length, the GS1 DataMatrix Guideline says a separator (FNC1, passed on by the scanner as the group separator character, ASCII 29) must follow them when another field comes after. No separator is needed after the last field. This is the detail that usually breaks batch capture.

Where the UK rules stand

Many packs carried a 2D barcode for the EU Falsified Medicines Directive. MHRA labelling guidance under the Windsor Framework says that from 1 January 2025 the directive no longer applies in Northern Ireland, and its safety features may be removed or covered. Under UK law the licence holder may still print a 2D DataMatrix encoding the product, expiry, batch, GTIN and serial number, but it is not compulsory. The printed expiry date and batch number rules are unchanged.

So expect a mix. Some packs will scan with batch and expiry. Some will not, and many supplies only have a linear barcode.

How to set it up, step by step

  1. Pick the hardware. A GS1 DataMatrix needs a scanner that reads in two dimensions, which normally means camera or imaging technology. GS1 notes this is different from the laser scanners used for linear barcodes, which cannot read it. A phone or tablet camera works. A handheld 2D imager is quicker at a busy delivery.
  2. Check the separator setting. If you use a USB or Bluetooth scanner, check that it passes on the group separator character. Test with a pack where the batch is not the last field and compare the result with the printed batch.
  3. Use GS1-aware software. A scan into a blank spreadsheet cell gives one long string of digits and letters. Software has to read the AIs and the separator to split out batch and expiry correctly.
  4. Link each product once. The GTIN identifies the product. The batch and expiry change with every delivery. So each product needs its barcode recorded once, then every later scan finds it.
  5. Check against the print at first. For the first few weeks, compare what was captured with the printed batch and expiry. Once a scanner and a supplier’s packs have proved reliable, spot-check instead.
  6. Keep a manual route. No DataMatrix, a damaged code or a missing separator means typing the batch and expiry from the pack. Make that easy, and never guess a batch number.

Doing it on paper or a spreadsheet

Writing batch and expiry by hand works, but it is slow and the print is small. Scanning into a spreadsheet saves typing the GTIN, but you then need formulas or a macro to split the string.

Where it breaks:

  • Batch length varies, so splitting at fixed positions gets it wrong.
  • The separator is invisible in a spreadsheet cell, or missing altogether, so formulas cannot find it.
  • The expiry comes out as YYMMDD and needs converting to a date.
  • Someone has to maintain the macro when it stops working.

How Stocta does this

Stocta reads the GTIN, batch number, expiry date and serial number from GS1 codes, including the DataMatrix on many UK medicine packs, and checks the GTIN’s check digit. When stock comes in, the batch and expiry fill in on their own. When stock goes out, a code that names a batch takes stock from that exact batch, not just the earliest one (see FEFO stock rotation).

It works with a phone or tablet camera in the browser, which reads GS1 DataMatrix, QR, EAN-13, EAN-8, UPC-A, UPC-E, Code 128, Code 39 and Code 93, or with a keyboard-style USB or Bluetooth scanner. It matches 13-digit EAN and 14-digit GTIN versions of the same code.

Its limits:

  • There is no built-in medicines database (no dm+d). Each product is scanned once to link its barcode. If a code is not recognised, you can create the item there and then.
  • If the scanner strips the separator, Stocta reads the product code, and the expiry when it comes before the batch in the code. It leaves the batch blank for you to type. Test your scanner with a few real packs first.
  • Packs without a DataMatrix, and most supplies, need batch and expiry typed in.
  • Stocta does not check packs against any external database. It reads what is on the pack.

More on how it fits a practice: stock control for GP surgeries and pricing.

Questions

Can a phone camera read the barcode on medicine packs?

Yes, a phone or tablet camera can read a GS1 DataMatrix, because it captures an image rather than a single line. What matters is the software: it has to understand GS1 codes to split the data into product code, batch and expiry.

Why does my scanner fill in the expiry but not the batch?

The batch number has no fixed length, so the code uses a separator character to mark where it ends when another field follows. Some scanners have a setting for passing that character on. If the scanner drops it, software cannot tell where the batch stops. Check the scanner settings, or type the batch from the pack.

Do all UK medicine packs have a 2D barcode?

No. Since 1 January 2025, MHRA guidance says the 2D DataMatrix is optional on UK packs. Packs may still carry one, but some do not, and many medical supplies only have an ordinary linear barcode. The printed batch number and expiry date are still required.

Does scanning the barcode check that the medicine is genuine?

Not for stock control. Scanning just reads the data on the pack. MHRA guidance says that from 1 January 2025 the EU Falsified Medicines Directive safety features no longer apply anywhere in the UK (GB-only licences were already exempt), and the 2D barcode is optional.

See it with your own stock

A 20-minute walkthrough using your practice’s own item list. £99 a month per site, unlimited staff and items.

Book a demoSee pricing

Pricing · GP surgeries · Stocta vs Sortly · Sortly alternatives · Stocta vs DBX ONE · Aesthetics clinics · Guides · Security & IG pack · Privacy · Terms

© 2026 Haris Nazir, trading as Stocta · London, United Kingdom · haris@stocta.com