Specimen Barcodes With Leading Zeros: Test the Whole Device-to-Lab Path
How IVD device teams define a specimen-identifier contract and run a synthetic round-trip test for leading zeros and HL7 reserved characters from label to LIS.

The short answer
Leading zeros are ordinary specimen-identifier content, not an anomaly. LabKey's LIMS documentation, for example, describes its generated barcode values as 9+ digit text strings with leading zeros, such as 000000001. The risk sits in the hops between systems. Any step that treats the identifier as a number can drop the zeros, and any step that writes HL7 v2 reserved characters into a message without escaping them can split one identifier across several fields. No FDA guidance or FDA-recognized standard names a leading-zero test. FDA's software and interoperability guidances do recommend system-level test protocols with expected results, observed results and pass/fail determinations, plus interface testing that simulates real-world use.
Where the test boundary sits. Draw it around the whole path the identifier travels in intended use, not around the instrument. That path runs through the label, the reader, the instrument software, any middleware, the interface message, the laboratory information system (LIS) order match and the result that comes back. When you do not supply the LIS, test against your interface specification plus at least one representative receiving system, and record which one you used.
Which identifier is authoritative. Decide it in the design inputs and write it down. In HL7 v2 the SPM segment separates SPM-2, the specimen identifier, from SPM-30, the accession ID. The specification says SPM-30 may not uniquely identify a specimen and that accession IDs are commonly reused. Pick one match key. Treat any other identifier as supporting data that is never used on its own to post a result.
Which cases to cover before release. At minimum, cover leading zeros, an all-zero value, a value at maximum width, a value one character over, a change in width, HL7 encoding characters, a case-sensitive pair, embedded whitespace and a character your contract explicitly rejects. Record what each hop should hold and what it actually held. The case set below is an editorial proposal consistent with FDA's verification expectations, not an FDA-mandated test.
Where specimen identifiers break on the device-to-lab path
A specimen identifier is usually created outside the device. An LIS or order-entry system assigns it, a printer at the collection site renders it as a barcode, and it reaches the analyzer already on the tube. From there a typical path has five more hops, and each one can change the string without raising an error:
Reader decode. The instrument's barcode reader turns the symbol into characters. Reader configuration decides exactly which characters are passed on, including any prefix or suffix.
Instrument software. The decoded value is stored, matched against a worklist or a host query, and attached to results.
Middleware or local database. The value passes through tables, queues and exports, and sometimes through spreadsheets used for service work or test-data preparation.
Interface message. The value is serialized into HL7 v2 or a vendor host protocol and parsed again on the other side.
LIS match and results return. The receiver looks up the order and posts the result. It may also send acknowledgments, corrections or new orders back with the identifier echoed.
Failures at these hops fall into two families. The first is numeric coercion. A layer treats the identifier as a number, so 000482910 becomes 482910. Integer database columns, numeric JSON fields, spreadsheet imports and numeric EDI data types all behave this way by design. The LabKey documentation shows both how ordinary the zero-padded shape is and how it can change. Its generated barcodes are 9+ digit text strings with leading zeros, and once more than a billion samples are defined, the barcode continues to 10 digits without leading zeros. The same documentation lets users mark their own Text or Integer field as a barcode field. Laboratories can therefore hold identifier contracts that differ in type as well as width, and a device that receives identifiers from such systems cannot assume one fixed shape.
GS1 documents a named, legitimate version of the same behavior. In GS1 XML, a Global Trade Item Number (GTIN) must be exactly 14 digits, so shorter GTINs are sent with leading zeros. In GS1 EANCOM, non-significant leading zeros must be removed because EDIFACT syntax does not allow them in numeric fields. GS1 states that all these formats still convey the same GTIN. That works only because GS1 defines the equivalence. None of the specimen-identifier sources reviewed here defines such a rule, so 000482910 and 482910 are different values unless your identifier contract explicitly says otherwise.
Silent coercion of identifier-like strings is documented well beyond the laboratory. Ziemann and colleagues (2016) reported that spreadsheet software with default settings converts gene symbols such as SEPT2 into dates (2-Sep) and identifiers such as 2310009E13 into floating-point numbers (2.31E+13). Of 3,597 published papers with supplementary Excel gene lists, 704, about one-fifth, contained such errors. That study measures gene lists, not specimens. It shows how routinely default type inference rewrites identifiers without warning. It does not show how often specimen mismatches occur.
The second family is delimiter collision. HL7 v2.7.1 Chapter 2 declares the encoding characters at the start of each message: the field separator (|), component separator (^), repetition separator (~), escape character (\) and subcomponent separator (&). The escape sequences \F\, \S\, \R\, \T\ and \E\ allow those characters to appear in text data, but the actual characters are reserved, and an escape sequence may not contain a nested escape sequence. A serializer that writes AB^12 into a field without escaping it creates a component boundary the receiver will honor. The LIS then sees AB, or sees 12 in the wrong component. Hyphens and underscores are not HL7 encoding characters. Test ^, &, ~, | and \, using the delimiters your interface actually declares.
What FDA expects, and what it does not name
FDA's final guidance Content of Premarket Submissions for Device Software Functions, issued June 14, 2023, superseded the May 2005 guidance on software contained in medical devices. Like all FDA guidance, it contains nonbinding recommendations. It describes software verification as confirmation by objective evidence that the output of a particular phase of development meets all the input requirements for that phase. Software testing is one of several verification activities.
For software testing as part of verification and validation, the Basic Documentation Level asks for a summary of unit, integration and system-level testing. It also asks for a system-level test protocol with expected results derived from software requirements, actual results that are observed and recorded, an objective pass/fail determination, and a system-level test report. The Enhanced Documentation Level adds unit- and integration-level protocols and reports. Applied to specimen identity, a requirement such as "transmit the identifier exactly as decoded" needs an expected value at each observation point and an observed value recorded beside it. A summary statement that the interface passed does not show which identifiers were exercised.
FDA's interoperability guidance, Design Considerations and Pre-market Submission Recommendations for Interoperable Medical Devices (September 6, 2017), is more specific about interfaces. It recommends that manufacturers perform a risk analysis and conduct appropriate testing that considers interoperability risks, anticipated users and reasonably foreseeable misuse. Its verification and validation examples include confirming that corrupted data can be detected and appropriately managed, and testing that the device continues to operate safely when data arrive outside the specified parameters. They also include assuring that reasonably foreseeable interactions do not cause incorrect operation of other networked systems, and conducting testing that simulates real-world use. The guidance asks the risk analysis to address boundary conditions and how the device handles corrupted data or data provided in the wrong format.
The same guidance answers part of the boundary question. For a device meant to work with many systems, it says it may be appropriate to test against the interface specification and with representative devices, and that the manufacturer should identify the representative device used. It also recommends that labeling include, as appropriate, a list of the data attributes being exchanged and a description of any boundary-condition testing, so a laboratory can see what the interface was verified to handle.
One vocabulary note applies to any record you write now. The Quality Management System Regulation (QMSR), FDA's amended 21 CFR part 820, took effect on February 2, 2026 and incorporates ISO 13485:2016 by reference. FDA's notice at the front of the 2023 software guidance says the QMSR does not use terms such as "Design Controls" and "Design Validation". The corresponding elements are described in ISO 13485:2016 clause 7.3 and its subclauses.
The rules your barcode must survive downstream
The identifier your device reads carries obligations on the laboratory side. Under CLIA, 42 CFR 493.1242 requires a laboratory to establish and follow written policies and procedures for specimen labeling, including patient name or unique patient identifier and, when appropriate, specimen source. The laboratory also needs procedures for specimen acceptability and rejection, and must document the date and time it receives a specimen. Those duties fall on the laboratory, not on the device manufacturer. They still have two consequences for the device team. The patient identifier on the label is not the specimen identifier the barcode carries, so keep the two as separate fields in your contract. And your device's rejection behavior feeds the laboratory's acceptability and rejection procedure, so it has to be visible to the operator rather than buried in a service record.
The US Core Data for Interoperability (USCDI) Specimen Identifier element sits in the Laboratory data class. Its description is a sequence of characters assigned by a laboratory for an individual specimen, with the accession number as an example. The data-element submission on the same page describes an alphanumeric string that uniquely identifies the specimen in the facility that assigned it. It notes that many LIS are specimen-centric and use this identifier as the primary key, and that it should not be reused over time, although reuse may still happen in some laboratories. A CDC comment adds that the identifier is assigned at collection and must travel with the specimen and all its parts, including to sub-laboratories.
The submission lists no applicable standard for the element itself. It notes that the FHIR Specimen resource calls this element accessionIdentifier, while HL7 v2 carries a separate specimen identifier and accession ID. Field names differ across standards, which is one more reason your contract has to name the field it relies on.
Label construction is covered by CLSI AUTO02-A2, Laboratory Automation: Bar Codes for Specimen Container Identification (second edition, January 6, 2006). CLSI has archived it but retains it as technically valid. It documents the form, placement and content of bar-code labels on specimen tubes used on clinical laboratory analyzers, and it uses Code 128. It recommends placing the label 9 mm from the bottom and 10 mm from the top of the container, with no more than three labels including the manufacturer's. FDA's recognized consensus standards entry recognizes AUTO02-A2 as a complete standard (recognition list 064, recognition number 7-331, date of entry May 26, 2025). The entry lists In Vitro Diagnostics as the primary specialty task group, with Software/Informatics as a second. Its stated rationale is scientific and technical merit and support for existing regulatory policy. Recognition is voluntary; it does not require anyone to use the standard.
The detail that matters most here is what AUTO02-A2 leaves open. Its scope says that, because of the diversity of patient data, the informational content used to identify the specimen is not specified. The standard tells you how to make a symbol any compliant analyzer can read, not what string the symbol should carry. Nothing in it stops a site from encoding values that your interface treats as numbers or as delimiters. That job belongs to your identifier contract.
CLSI AUTO07-A, Laboratory Automation: Data Content for Specimen Identification (first edition, June 20, 2004), is also archived but retained as technically valid. CLSI describes it as an extension of AUTO02. It defines a format for specimen numbering so that specimens can be processed by independent sites and still be linked to the patient and the requesting facility. This article does not reconstruct that format. If your customers use AUTO07-style numbering, take the field structure from the standard itself and add representative values to your test set.
Fix the identifier contract before writing test cases
Test cases need expected results, and you cannot write an expected result for an identifier whose type, width and character set nobody has decided. Settle the contract first. Each decision below closes a whole family of failures and becomes a design input that the round-trip cases verify. The example choices are illustrative. Set your own from the label, reader, interface and LIS constraints you actually support.
| Decision | Example choice (illustrative) | Failure family it closes |
|---|---|---|
| Authoritative match key | SPM-2 carries the scanned identifier; SPM-30 accession ID is sent when available but never used alone to post a result | Ambiguous matches when an accession ID covers more than one specimen or is reused |
| Data type | Text at every layer: firmware buffers, database columns, object models, queues and exports | Numeric coercion that strips leading zeros |
| Width | 7 to 20 characters; no hop adds or removes padding | Silent truncation, and width changes such as a fixed 9-digit parser meeting a 10-digit value |
| Character set and case | A–Z, a–z, 0–9 and hyphen; case-sensitive; everything else rejected | Delimiter collision, whitespace trimming and case folding |
| Reserved characters | Rejected at the instrument; if the contract must allow them, escaped on send and restored on receipt | Fields split or shifted by unescaped ^, &, ~, | or \ |
| Equivalence | None: no padding, case or whitespace normalization unless the contract defines it | Two different specimens treated as one |
| Rejection behavior | Value never truncated or guessed; result held and not transmitted; operator alerted; event recorded | Silent mismatches that look like successful runs |
The authoritative-field decision deserves the most care. In the HL7 v2+ SPM segment, SPM-2 contains a unique identifier for the specimen as referenced by the placer application, the filler application or both. SPM-30 carries accession identifiers. The specification notes that an accession ID may or may not identify a single specimen, depending on laboratory practice, and that accession IDs are commonly reused over time. Because USCDI uses the accession number as its example of a specimen identifier, the tube barcode may well carry what the laboratory calls an accession number. Write down which value the barcode carries, which message field transports it and which field the receiver uses to post results. Then make the same choice in the analyzer, middleware and LIS configuration. Whether a resent or corrected result is the same result is a separate decision, covered in our guide to retransmitted device results.
Strict text typing removes coercion at the source, because a value that is never a number cannot lose its zeros. Escaping is the second line of defense. If your contract permits any HL7 encoding character, the sender must substitute the escape sequence before transmission and the receiver must restore it, so AB^12 travels as AB\S\12. If the contract does not permit them, reject the value at the first hop rather than relying on a receiver to cope.
Where the label printer, middleware and LIS come from different vendors, the contract is also the boundary document. Your verification covers what you supply: reader configuration, instrument software, and the messages the instrument sends and receives. For everything else, test against the interface specification you publish, using an LIS simulator and at least one representative receiving system. Record which ones you used, and state the identifier constraints in your interface documentation. That follows FDA's interoperability recommendations and lets a laboratory repeat the critical cases during its own installation checks. For the wider standards landscape, see our medical device interoperability guide.
The round-trip test table: synthetic identifier cases
The table applies the example contract above: text, 7 to 20 characters, A–Z, a–z, 0–9 and hyphen, case-sensitive, no normalization, reserved characters rejected. All values are synthetic. Run every case in both directions, from label to LIS result posting and from LIS orders and acknowledgments back to the instrument. A case passes only when the observed value matches the expected value at every hop, or when the rejection happens at the expected hop and is visible to the operator.
| Case | Synthetic value | What it probes | Reader and instrument | Message and middleware | LIS match and return | Fail signal |
|---|---|---|---|---|---|---|
| RT-01 | 000482910 | Leading zeros in a 9-digit zero-padded value | Decoded and stored as 000482910 (9 characters) | SPM-2 carries 000482910 unchanged | Matches order 000482910; returned messages echo 000482910 | 482910 appears at any hop, or the result posts to decoy order 482910 |
| RT-02 | 000000000 | All-zero value | Handled as the contract states; this example accepts it as a distinct value | Sent as 000000000, never as 0, blank or null | Matches only order 000000000 | Value becomes 0, blank or null, or matches a default or placeholder record |
| RT-03 | 00000000000000482910 | Maximum width (20 characters) with leading zeros | All 20 characters decoded and stored | All 20 characters sent; no field-length truncation | Matches the 20-character order | Any character lost, including zeros |
| RT-04 | 000000000000000482910 | Width overflow (21 characters) | Rejected at the instrument; operator alerted; event recorded | No result message sent | No posting; order stays open | Value truncated to 20 characters and matched, or sent anyway |
| RT-05 | 1000000000 | Width change: 10 digits after a 9-digit series | Accepted as a 10-character value | Sent unchanged | Matches order 1000000000 | Rejected or cut by a parser that assumes 9 digits |
| RT-06 | AB^12&34 | HL7 component (^) and subcomponent (&) separators | Rejected as outside the character set; if your contract permits them, stored unchanged | If permitted: sent as AB\S\12\T\34 | If permitted: restored to AB^12&34 and matched | Extra components appear, value cut to AB, or escape text stored literally |
| RT-07 | AB|12\34 | HL7 field separator (|) and escape character (\) | Rejected; if permitted, stored unchanged | If permitted: sent as AB\F\12\E\34 | If permitted: restored to AB|12\34 | Following fields shift, the segment fails to parse, or value cut to AB |
| RT-08 | AB1234c and AB1234C | Case-sensitive pair | Both stored as distinct values | Both sent with case preserved | Two orders, two results, no merge | One result overwrites or merges with the other, or both match one order |
| RT-09 | 0048 2910 | Embedded whitespace | Rejected at the instrument | No result message sent | No posting | Space removed and decoy 00482910 matched, or value cut to 0048 |
| RT-10 | AB_1234 | Character the contract explicitly rejects (underscore) | Rejected; operator alerted | No result message sent | No posting | Underscore stripped or replaced and decoy AB1234 matched |
Seed decoy records. A stripped or truncated value usually fails as "no match", which looks harmless in a test record. The dangerous failure is a match to the wrong record. Seed the LIS simulator with decoy orders equal to each likely corruption: 482910 for RT-01, 0 for RT-02, the first 20 characters of RT-04, AB for RT-06 and RT-07, 00482910 and 0048 for RT-09, and AB1234 for RT-10. A coercion bug then shows up as a result posted to a decoy, not as a vague mismatch. The all-zero case is a judgment call. Some teams reserve it as a placeholder and reject it, and either choice is defensible if the contract states it.
Record values and lengths at each hop. For each case, capture the decoded string as the instrument reports it, the stored value, and the raw outbound and inbound message text before any parser touches it. Also capture the LIS record the result posted to and the identifier echoed in acknowledgments or returned results. Record lengths as well as values. A report reader can easily miss the difference between 000482910 and 00482910, but not the difference between 9 and 8. Compare expected and observed values in the test harness character by character rather than by eye.
Keep the test inputs honest. Where you can, print the test labels through the same label path your customers use, because a label template that formats the value as a number drops the zeros before the reader ever sees them. Prepare the case list as text, too. If it passes through a spreadsheet on its way into the simulator, the zeros can vanish from both the input and the expected value. The run then reports a false pass.
Recording the evidence in design verification records
Under the QMSR, the requirements formerly called design controls sit in ISO 13485:2016 clause 7.3. The round-trip suite is design and development verification evidence (clause 7.3.6). Later reruns fall under control of design and development changes (clause 7.3.9). Keep both in the design and development file that clause 7.3.10 requires, the record set many teams still call the design history file.
A traceability chain for specimen identity can be short. The entries below are illustrative:
Hazard: a result is associated with the wrong specimen because the identifier changed between hops (from your ISO 14971 risk analysis).
Requirement: the instrument stores and transmits the specimen identifier as text, exactly as decoded, 7 to 20 characters, case preserved, and rejects out-of-contract values without transmitting a result.
Risk controls: text-only typing at every layer, contract validation at the first hop, escaping on send if reserved characters are ever allowed, and operator-visible rejection.
Verification: a system-level round-trip protocol covering cases RT-01 to RT-10, with expected values per hop.
Record: the system-level test report with observed values, pass/fail per case, the software version tested, the reader configuration, and the simulator and representative systems used.
Keep two layers apart in that record. FDA's software guidance recommends expected results derived from requirements, actual results that are observed and recorded, an objective pass/fail determination and a test report, along with a history of tested software versions. Raw message captures, reader configuration exports and decoy-record seeding are good practice that makes a failed case reproducible. They are not named FDA requirements. The same guidance recommends regression analysis, plus regression testing with pass/fail results where needed, when software changes. That is the natural trigger for rerunning the suite. For the wider distinction between the two activities, see our software verification and validation guide.
How adjacent fields already handle this
Interface-validation guidance for pharmaceutical quality-control laboratories already spells out this checklist. A US Validation Services knowledge-base article on analytical instrument–LIMS interface validation says sample and test identifiers are the primary link between the physical sample, the instrument record, the LIMS record and the reported result. It lists controls for identifier format and length, uniqueness, case sensitivity, spaces and special characters, leading zeros, prefixes and suffixes, and barcode interpretation. It warns that truncation, removal of leading zeros, character substitution or normalization can associate a result with the wrong sample. It recommends testing identifiers at maximum permitted length and with allowed special characters, and says the interface should reject or quarantine results that cannot be matched unambiguously to an authorized sample. This is consultancy guidance written for GMP laboratories working under 21 CFR part 211 and part 11, not an IVD requirement. The failure mechanism it describes is still the one this article tests.
Device teams also handle leading zeros in another setting: GTINs in UDI and supply-chain data, as covered in our labeling and UDI guide. GS1's rules there show the opposite design choice. GS1 defines when padded and unpadded forms are the same GTIN, so an EANCOM interface can drop zeros safely. Do not reuse normalization code written for GTINs on specimen identifiers, which have no defined equivalence unless your contract creates one.
The spreadsheet study offers a narrower lesson. The gene-name errors persisted because default settings changed identifiers without any user action, and the output still looked like valid data. Ziemann and colleagues suggested that journals adapt the authors' scripts to screen supplementary files. For a device team, the equivalent is automated, character-level comparison of expected and observed identifiers in the test harness, plus the same check in any service or export tool that handles identifiers.
Limits, evidence quality, and when to retest
None of this argues against barcoding. A CDC-funded Laboratory Medicine Best Practices systematic review (Snyder et al., 2012) included 17 observational studies, 10 on patient specimens and 7 on point-of-care testing, and all 17 favored barcoding. The meta-analysis mean odds ratios were 4.39 (95% CI 3.05–6.32) for barcoding systems and 5.93 (95% CI 5.28–6.67) for point-of-care testing. The authors rated the overall strength of evidence high and the effect size substantial, and recommended barcoding as an evidence-based best practice. Unpublished studies made up almost half of that evidence.
Labeling errors still occur. In a College of American Pathologists Q-Probes study, 147 laboratories reviewed more than 3.3 million specimen labels and found labeling errors at 0.92 per 1,000 labels (Wagar et al., 2008). Those errors were mislabeled, unlabeled, partially labeled or incompletely labeled specimens and illegible labels, not interface or format errors. The paper cites previously reported specimen identification error rates of 0.1% to 5%. It found lower labeling error rates in laboratories with current, ongoing quality monitors for specimen identification (P = .008). It lists the consequences of misidentification as delayed diagnosis, additional testing, treatment of the wrong patient for the wrong disease and severe transfusion reactions.
What no public source establishes is how often leading-zero or reserved-character mismatches reach patients. We found no dataset that separates them from other identification errors, so do not put an invented probability in the risk file. The severity side is clear from the consequences above. On the probability side, record that public incidence data are absent, and let verified risk controls, rather than a low probability estimate, carry the argument.
Rerun the suite, or the affected cases, when any of these change:
Reader hardware, firmware or decode configuration, including prefix, suffix and symbology settings.
Instrument software that touches identifier storage, matching or the host interface, as your regression analysis determines.
Middleware, database schema or export tooling in the identifier path.
A new LIS, middleware or interface-engine connection, or a change to the interface specification, such as field lengths or declared encoding characters.
A customer's identifier format: width, prefix, character set, a move to AUTO07-style numbering, or a new symbology.
Complaints or service reports of unmatched, duplicated or misposted results.
The order of work matters more than the size of the test set. Decide the contract, make every hop enforce it, then prove it with synthetic values that each target one way the string can change. A test that runs only inside the instrument leaves untested the hops where the documented failure mechanisms sit.