implement-pharma-serialisation
정보
이 스킬은 개발자가 EU FMD 및 미국 DSCSA와 같은 글로벌 규정을 준수하는 제약 직렬화 시스템을 구현하는 데 도움을 줍니다. 고유 식별자 생성, 집계 계층 구조, EPCIS 데이터 교환 및 검증 엔드포인트 통합을 다룹니다. 직렬화 제품 출시 시, 국가 검증 시스템과 통합할 때 또는 규정을 준수하는 거래 교환을 설계할 때 사용하십시오.
빠른 설치
Claude Code
추천npx skills add pjt222/agent-almanac -a claude-code/plugin add https://github.com/pjt222/agent-almanacgit clone https://github.com/pjt222/agent-almanac.git ~/.claude/skills/implement-pharma-serialisationClaude Code에서 이 명령을 복사하여 붙여넣어 스킬을 설치하세요
문서
Implement Pharmaceutical Serialisation
Set up pharmaceutical serialisation systems for regulatory compliance with global track-and-trace mandates.
When Use
- Implement serialisation for new product launch in EU or US market
- Integrate with European Medicines Verification System (EMVS/NMVS)
- Design DSCSA-compliant transaction information exchange
- Build or integrate EPCIS event repository for supply chain visibility
- Extend serialisation to additional markets (China NMPA, Brazil ANVISA)
Inputs
- Required: Product information (GTIN, product code, dosage form, pack sizes)
- Required: Target market regulations (EU FMD, DSCSA, or both)
- Required: Packaging hierarchy (unit, bundle, case, pallet)
- Optional: Existing ERP/MES system details for integration
- Optional: Contract manufacturer serialisation capabilities
- Optional: Verification endpoint specifications
Steps
Step 1: Understand Regulatory Landscape
| Regulation | Region | Key Requirements | Deadline |
|---|---|---|---|
| EU FMD (2011/62/EU) | EU/EEA | Unique identifier + tamper-evident feature on each unit | Live since Feb 2019 |
| DSCSA | USA | Electronic, interoperable tracing at package level | Full enforcement Nov 2024+ |
| China NMPA | China | Unique drug traceability code per minimum saleable unit | Rolling |
| Brazil ANVISA (SNCM) | Brazil | Serialisation of pharmaceuticals with IUM | Rolling |
| Russia MDLP | Russia | Crypto-code per unit, mandatory scanning | Live |
Key data elements per regulation:
EU FMD unique identifier (per Delegated Regulation 2016/161):
- Product code (GTIN-14 from GS1)
- Serial number (up to 20 alphanumeric characters, randomised)
- Batch/lot number
- Expiry date
DSCSA transaction information:
- Product identifier (NDC/GTIN, serial number, lot, expiry)
- Transaction information (date, entities, shipment details)
- Transaction history and transaction statement
- Verification at package level
Got: Clear understanding of which regulations apply to each product-market combination.
If fail: Engage regulatory affairs to confirm market requirements before proceeding.
Step 2: Design Serialisation Data Model
-- Core serialisation data model
CREATE TABLE serial_numbers (
id BIGSERIAL PRIMARY KEY,
gtin VARCHAR(14) NOT NULL, -- GS1 GTIN-14
serial_number VARCHAR(20) NOT NULL, -- Unique per GTIN
batch_lot VARCHAR(20) NOT NULL,
expiry_date DATE NOT NULL,
status VARCHAR(20) DEFAULT 'ACTIVE', -- ACTIVE, DECOMMISSIONED, DISPENSED, etc.
created_at TIMESTAMPTZ DEFAULT NOW(),
UNIQUE(gtin, serial_number)
);
-- Aggregation hierarchy
CREATE TABLE aggregation (
id BIGSERIAL PRIMARY KEY,
parent_code VARCHAR(50) NOT NULL, -- SSCC or higher-level code
parent_level VARCHAR(10) NOT NULL, -- CASE, PALLET, BUNDLE
child_code VARCHAR(50) NOT NULL, -- GTIN+serial or child SSCC
child_level VARCHAR(10) NOT NULL, -- UNIT, BUNDLE, CASE
aggregation_event_id UUID NOT NULL,
created_at TIMESTAMPTZ DEFAULT NOW()
);
-- EPCIS events
CREATE TABLE epcis_events (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
event_type VARCHAR(30) NOT NULL, -- ObjectEvent, AggregationEvent, TransactionEvent
action VARCHAR(10) NOT NULL, -- ADD, OBSERVE, DELETE
biz_step VARCHAR(100), -- urn:epcglobal:cbv:bizstep:commissioning
disposition VARCHAR(100), -- urn:epcglobal:cbv:disp:active
read_point VARCHAR(100), -- urn:epc:id:sgln:location
event_time TIMESTAMPTZ NOT NULL,
event_timezone VARCHAR(6) NOT NULL,
payload JSONB NOT NULL,
created_at TIMESTAMPTZ DEFAULT NOW()
);
Aggregation hierarchy:
Pallet (SSCC)
└── Case (SSCC)
└── Bundle (GTIN + serial) [optional level]
└── Unit (GTIN + serial)
Got: Data model supports full pack hierarchy with EPCIS event tracking.
If fail: Existing ERP schema conflicts? Design integration layer rather than modifying ERP direct.
Step 3: Implement Serial Number Generation
import secrets
import string
def generate_serial_number(length: int = 20, charset: str = None) -> str:
"""Generate a random serial number compliant with GS1 standards.
EU FMD requires randomised serial numbers to prevent prediction.
Max 20 characters, alphanumeric (GS1 Application Identifier 21).
"""
if charset is None:
# GS1 AI(21) allows: digits, uppercase, lowercase, and some special chars
# Most implementations use alphanumeric only for interoperability
charset = string.ascii_uppercase + string.digits
return ''.join(secrets.choice(charset) for _ in range(length))
def generate_serial_batch(gtin: str, batch_lot: str, expiry: str, count: int) -> list:
"""Generate a batch of unique serial numbers for a production run."""
serials = set()
while len(serials) < count:
serials.add(generate_serial_number())
return [
{
"gtin": gtin,
"serial_number": sn,
"batch_lot": batch_lot,
"expiry_date": expiry,
"status": "COMMISSIONED"
}
for sn in serials
]
Got: Serial numbers cryptographically random, unique per GTIN, stored before printing.
If fail: Uniqueness collision occurs? Regenerate conflicting serial + log event.
Step 4: Implement GS1 DataMatrix Encoding
2D DataMatrix barcode encodes GS1 element string:
(01)GTIN(21)Serial(10)Batch(17)Expiry
Example:
(01)05012345678901(21)A1B2C3D4E5(10)LOT123(17)261231
Where:
- AI(01) = GTIN-14
- AI(21) = Serial number
- AI(10) = Batch/lot number
- AI(17) = Expiry date (YYMMDD)
GS1 DataMatrix uses FNC1 as separator (GS character, ASCII 29) between variable-length fields.
def encode_gs1_element_string(gtin: str, serial: str, batch: str, expiry: str) -> str:
"""Encode GS1 element string for DataMatrix printing.
FNC1 (GS character \\x1d) separates variable-length fields.
AI(01) and AI(17) are fixed length, so no separator needed after them.
AI(21) and AI(10) are variable length and need FNC1 terminator.
"""
GS = '\x1d' # GS1 FNC1 / Group Separator
return f"01{gtin}21{serial}{GS}10{batch}{GS}17{expiry}"
Got: Encoded strings verified by scanning test prints with GS1-certified verifier (ISO 15415 grade C or above).
If fail: Scan verification fails? Check print quality, quiet zones, encoding order.
Step 5: Integrate with National Verification Systems
EU FMD — EMVS/NMVS Integration
MAH → Upload serial data → EU Hub → Distribute to National Systems (NMVS)
├── Germany (securPharm)
├── France (CTS)
├── Italy (AIFA)
└── ... 31 markets
API operations:
- Upload (MAH → EU Hub): Batch upload of commissioned serial numbers
- Verify (Pharmacy → NMVS): Check serial status before dispensing
- Decommission (Pharmacy → NMVS): Mark as dispensed at point of sale
- Reactivate (MAH → NMVS): Reverse accidental decommission
DSCSA — Verification Router Service
Trading Partner A → VRS Request → Verification Router → MAH's VRS → Response
Implement VRS responder endpoint:
# Simplified VRS endpoint (DSCSA verification)
from fastapi import FastAPI, HTTPException
app = FastAPI()
@app.get("/verify/{gtin}/{serial}/{lot}/{expiry}")
async def verify_product(gtin: str, serial: str, lot: str, expiry: str):
"""DSCSA product verification endpoint."""
record = await lookup_serial(gtin, serial)
if record is None:
return {"verified": False, "reason": "SERIAL_NOT_FOUND"}
if record.batch_lot != lot or str(record.expiry_date) != expiry:
return {"verified": False, "reason": "DATA_MISMATCH"}
if record.status != "ACTIVE":
return {"verified": False, "reason": f"STATUS_{record.status}"}
return {"verified": True, "status": record.status}
Got: Verification endpoints respond within 1 second with correct status.
If fail: National system upload fails? Retry with exponential backoff + alert operations.
Step 6: Implement EPCIS Event Capture
Record supply chain events in EPCIS 2.0 format:
{
"@context": "https://ref.gs1.org/standards/epcis/2.0.0/epcis-context.jsonld",
"type": "ObjectEvent",
"eventTime": "2025-03-15T10:30:00.000+01:00",
"eventTimeZoneOffset": "+01:00",
"epcList": ["urn:epc:id:sgtin:5012345.067890.A1B2C3D4E5"],
"action": "ADD",
"bizStep": "urn:epcglobal:cbv:bizstep:commissioning",
"disposition": "urn:epcglobal:cbv:disp:active",
"readPoint": {"id": "urn:epc:id:sgln:5012345.00001.0"},
"bizLocation": {"id": "urn:epc:id:sgln:5012345.00001.0"}
}
Key business steps in pharma supply chain:
commissioning— serial number assigned to physical unitpacking— aggregation into cases/palletsshipping— departure from locationreceiving— arrival at locationdispensing— supplied to patient (decommission trigger)
Got: Every status change generates EPCIS event with correct timestamps + locations.
If fail: Failed event capture must be queued + retried; never silently dropped.
Checks
- Serial numbers randomised + unique per GTIN
- GS1 DataMatrix encoding verified by barcode scanner (ISO 15415 grade C+)
- Aggregation hierarchy correctly links units → bundles → cases → pallets
- National verification system integration tested (upload, verify, decommission)
- EPCIS events captured for all business steps
- Verification endpoint responds within 1 second
- Exception handling covers upload failures, scan failures, network errors
Pitfalls
- Sequential serial numbers: EU FMD explicit requires randomisation to prevent counterfeiting. Never use sequential numbering.
- Aggregation errors: Disaggregation (breaking case) must update hierarchy. Shipping case with wrong child associations → verification failures downstream.
- Timezone handling: EPCIS events must include timezone offset. Using local time without offset → event ordering ambiguity across sites.
- Late uploads: Serial data must be uploaded to national systems before product enters supply chain. Late upload = product flagged suspicious at pharmacy.
- Ignoring exceptions: Legitimate products get flagged (false alerts) regular. Process for investigating + resolving alerts essential.
See Also
perform-csv-assessment— validate serialisation system as computerised systemconduct-gxp-audit— audit serialisation processesimplement-audit-trail— audit trail for serialisation eventsserialize-data-formats— general data serialisation (different domain, complementary concepts)design-serialization-schema— schema design for data exchange formats
GitHub 저장소
연관 스킬
content-collections
메타이 스킬은 콘텐츠 콜렉션(Content Collections)을 위한 프로덕션 검증된 설정을 제공합니다. 콘텐츠 콜렉션은 Markdown/MDX 파일을 Zod 검증이 포함된 타입 안전한 데이터 콜렉션으로 변환해주는 TypeScript 최우선 도구입니다. 블로그, 문서 사이트 또는 콘텐츠 중심의 Vite + React 애플리케이션을 구축할 때 타입 안전성과 자동 콘텐츠 검증을 보장하기 위해 사용하세요. Vite 플러그인 구성과 MDX 컴파일부터 배포 최적화 및 스키마 검증에 이르기까지 모든 것을 다룹니다.
polymarket
메타이 스킬은 개발자들이 Polymarket 예측 시장 플랫폼을 활용한 애플리케이션을 구축할 수 있도록 지원하며, 거래 및 시장 데이터를 위한 API 통합 기능을 포함합니다. 또한 WebSocket을 통한 실시간 데이터 스트리밍을 제공하여 실시간 거래와 시장 활동을 모니터링할 수 있습니다. 이를 통해 거래 전략을 구현하거나 실시간 시장 업데이트를 처리하는 도구를 생성하는 데 활용할 수 있습니다.
creating-opencode-plugins
메타이 스킬은 개발자들이 명령어, 파일, LSP 작업 등 25개 이상의 이벤트 유형에 연결되는 OpenCode 플러그인을 만들 수 있도록 돕습니다. JavaScript/TypeScript 모듈을 위한 플러그인 구조, 이벤트 API 명세, 구현 패턴을 제공합니다. OpenCode AI 어시스턴트의 라이프사이클을 사용자 정의 이벤트 기반 로직으로 가로채거나, 모니터링하거나, 확장해야 할 때 사용하세요.
sglang
메타SGLang은 RadixAttention 프리픽스 캐싱을 활용하여 JSON, 정규식, 에이전트 워크플로우를 위한 고속 구조화 생성에 특화된 고성능 LLM 서빙 프레임워크입니다. 특히 반복되는 프리픽스가 있는 작업에서 상당히 빠른 추론 속도를 제공하여 복잡한 구조화 출력 및 다중 턴 대화에 이상적입니다. 제약 디코딩이 필요하거나 광범위한 프리픽스 공유가 있는 애플리케이션을 구축할 때는 vLLM과 같은 대안보다 SGLang을 선택하십시오.
