udi-validator
Validate and parse medical device UDI (Unique Device Identification) strings: GS1 element strings (AI parser + GTIN mod-10 check digit + date fields), HIBCC format detection, and ICCBBA (ISBT 128) detection. Helps regulatory affairs and quality teams quickly spot malformed UDI-DI / UDI-PI data before database submission.
Latest: v1.0.0
Bilingual rewrite (full EN+ZH, English first)
凡自治之物 · LGD 治理学 · 创造术家族 | 评测协议:skill-quality-gate
English
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).
- 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.
- Triaging supplier label samples: which issuing agency (GS1 / HIBCC / ICCBBA) the barcode belongs to.
Issuing-agency triage
| Agency | Typical prefix | Validation |
|---|---|---|
| GS1 | starts with 01 | full |
| HIBCC | starts with + | format detection only |
| ICCBBA (ISBT 128) | starts with = | detection only |
Usage
python scripts/udi_validate.py "0104006381333931"
python scripts/udi_validate.py --file barcode_dump.txt
python scripts/udi_validate.py --checkdigit 0400638133393
Exit 0 = all valid; 1 = any problem. Per input it reports: detected agency, parsed AI fields, check-digit verdict, date-field verdicts.
Flow
- Detect the issuing agency (GS1 / HIBCC / ICCBBA).
- Parse AI fields; verify check digit and dates.
- Emit per-item verdicts; point at the first failing position.
Known limits
- HIBCC check-char arithmetic and ICCBBA identity verification are not implemented; final validation must use official agency tools.
- Validates structure, not whether the UDI-DI actually exists in a regulatory database (online query required).
- Date day
00(GS1 "day unknown") is accepted and flagged.
Evidence & safety
- Evidence: TBD. Version: 1.0.1. Security: no independent scan (TBD).
中文
何时用
- 提交 NMPA UDI / FDA GUDID / EU EUDAMED 前校验 UDI-DI/UDI-PI 字符串结构。
- 校验 GS1 元素字符串提交前是否结构合法。
- 从原始 UDI 字符串提取结构化字段(GTIN、批号、效期、序列号、生产日期)。
- 供应商标签条码分诊:判断条码属于哪个发码机构(GS1 / HIBCC / ICCBBA)。
发码机构分诊
| 发码机构 | 典型前缀 | 校验程度 |
|---|---|---|
| GS1 | 以 01 开头 | 完整校验 |
| HIBCC | 以 + 开头 | 仅格式识别 |
| ICCBBA (ISBT 128) | 以 = 开头 | 仅识别 |
用法
python scripts/udi_validate.py "0104006381333931"
python scripts/udi_validate.py --file barcode_dump.txt
python scripts/udi_validate.py --checkdigit 0400638133393
退出码 0 = 全部合法;1 = 有任意问题。每个输入报告:识别的发码机构、解析的 AI 字段、校验位结论、日期字段结论。
流程
- 检测发码机构(GS1 / HIBCC / ICCBBA)。
- 解析 AI 字段并校验校验位/日期。
- 输出逐项结论,定位首个失败位置。
已知局限
- HIBCC 校验字符算法与 ICCBBA 身份核验未实现;最终校验须用官方机构工具/数据库。
- 本脚本校验结构,不校验 UDI-DI 是否真实存在于监管数据库(NMPA UDI / GUDID / EUDAMED)——需在线查询。
- 日期日值
00(GS1 "日期未知")会被接受并标记。
证据与安全声明
- 证据:TBD(暂无评测/徽章链接;产生后在此更新实际链接)
- 版本:1.0.1
- 安全:未做独立安全扫描(TBD),结论待补;补全前不作推荐背书。
