UDI Validator (医疗器械唯一标识校验)
When to Use
- Reviewing UDI-DI / UDI-PI strings on labels, IFUs, or UDI database submissions (NMPA UDI 数据库, FDA GUDID, EU EUDAMED, Japan PS-HOT etc.)
- Checking whether a GS1 element string is structurally valid before submission
- Extracting structured fields (GTIN, lot, expiry, serial, manufacture date) from a raw UDI string
- Quickly triaging label samples from suppliers: which issuing agency (GS1 / HIBCC / ICCBBA) does the barcode belong to
Issuing Agency Quick Triage
| Issuing agency | Typical prefix | Full validation |
|---|---|---|
| GS1 | starts with 01 (GTIN element string) | ✅ supported by this skill |
| HIBCC | starts with + | partial (format detection only) |
| ICCBBA (ISBT 128) | starts with = | detection only |
How to Validate
Run the bundled script:
# single string or multiple strings
python scripts/udi_validate.py "0104006381333931" "0104006381333931 17 261031 10 AB1234"
# GS1 element string with group separator (ASCII 29) — pass raw bytes via --file
python scripts/udi_validate.py --file barcode_dump.txt
# compute GTIN-14 check digit for a 13-digit prefix
python scripts/udi_validate.py --checkdigit 0400638133393
Exit code is 0 when all inputs are valid, 1 when any problem is found. The report lists, for each input:
- detected issuing agency
- parsed fields (AI table with human-readable names)
- check-digit verdict
- date field verdicts (expiry / manufacture date; flagged in the past for expiry)
Covered GS1 Application Identifiers (UDI-relevant)
| AI | Meaning | Length | |---|---|---| | 01 / 02 | GTIN / GTIN of contained items | 14 digits (check digit verified) | | 10 | Batch / lot | variable, ≤20 chars | | 11 | Production date (YYMMDD) | 6 digits | | 17 | Expiration date (YYMMDD) | 6 digits | | 21 | Serial number | variable, ≤20 chars | | 20 | Internal product variant | 2 digits | | 240 / 241 / 250 / 251 | Additional / customer / matl / production id | variable ≤30 | | 30 | Count of items | variable ≤8 digits | | 37 | Count of contained items | variable ≤8 digits | | 710–713 | National healthcare reimbursement numbers | variable ≤20 |
Variable-length AIs are terminated by the GS1 group separator (FNC1, ASCII 29) or end of string — exactly as encoded in GS1-128 / GS1 DataMatrix barcodes.
Known Limits (be explicit with users)
- HIBCC check-character arithmetic and ICCBBA identity verification are not implemented; the script detects and segments them but final validation must use the official agency tools/databases.
- The script validates structure, not whether a UDI-DI actually exists in a regulatory database (NMPA UDI 数据库 / GUDID / EUDAMED) — those require online queries.
- Date day value
00(GS1 "day unknown") is accepted and flagged.
Output Discipline
- Always show the parsed field table and the verdict per input.
- If a string fails, point at the first failing position (AI, length, or check digit) instead of a bare "invalid".
- Never invent a corrected UDI; suggest what to re-check with the labeler instead.
Scan to join WeChat group