Skip to content

Add the made-to-order, Italian NHRN and person identifiers (193 -> 205) - #9

Merged
MaximBelov merged 1 commit into
masterfrom
feat/person-and-mto-ais
Aug 13, 2026
Merged

MaximBelov merged 1 commit into
masterfrom
feat/person-and-mto-ais

Conversation

@MaximBelov

Copy link
Copy Markdown
Owner

Adds the identifiers @guillaumegarcia13's fork has been carrying since 2025, so this fork stops trailing it. The identifier list is theirs; the date handling is not, for the reason below.

Coverage goes from 193 to 205:

AI Title Format
03 MTO GTIN fixed, 14
716 NHRN AIC (Italy) variable
7250 DOB YYYYMMDD
7251 DOB TIME YYYYMMDDHHMM
7252 BIOLOGICAL SEX fixed, 1
7253–7259 FAMILY NAME, GIVEN NAME, NAME SUFFIX, FULL NAME, PERSON ADDR, BIRTH SEQUENCE, BABY variable

The 725x block identifies a patient rather than a trade item, which is what makes it useful on a healthcare label alongside the GTIN, expiry and batch.

Why the dates needed their own parser

7250 and 7251 are the first date elements in this library to carry a four digit year. Every other date AI is YYMMDD, and parseDate reads exactly six digits.

Routing 7250 through parseDate is not merely inaccurate, it corrupts the rest of the barcode:

(7250)19850630
  -> parseDate takes "198506" as YYMMDD  -> a date in 2026
  -> leaves "30" behind                  -> parsed as an AI of its own
  -> the barcode comes back with TWO elements and no error

So this adds parseLongDate, which reads the year as given — there is no century to guess at, and the sliding window that parseDate applies would be actively wrong here — and validates month, day, and for 7251 hours and minutes. A short or non-numeric date is rejected rather than silently truncated.

That is the one place this deliberately diverges from the fork it takes the list from: guillaumegarcia13/master declares parseDate("7250", "DOB") and reproduces the behaviour above.

Tests

spec/ApplicationIdentifiersSpec.js grows from 193 to 205 entries, so every new identifier is covered by the table that checks each one comes back under its own AI.

spec/PersonApplicationIdentifiersSpec.js adds 17 specs for the parts a table cannot express: that 7250 reads a four digit year, that it consumes all eight digits and leaves no spurious element, that it does not slide 1920 into this century, that impossible months, days, hours and minutes are rejected, and a full healthcare barcode carrying GTIN, expiry, batch and patient together.

232 specs, 0 failures. Existing specs are untouched.

Adds 03 MTO GTIN, 716 NHRN AIC and the person related block 7250-7259 that
GS1 uses to identify a patient rather than a trade item, taking the coverage
from 193 identifiers to 205.

7250 and 7251 are the first date elements here to carry a four digit year, so
they get their own parser rather than reusing parseDate. Reading YYYYMMDD with
the two digit parser is not merely inaccurate: it takes the first six digits as
a date, so "725019850630" yields a date in 2026 and leaves "30" behind to be
parsed as an AI of its own, and the barcode comes back with a spurious extra
element rather than an error. The new parser reads the year as given, with no
century to guess at, and validates month, day and, for 7251, hours and minutes.

The identifier list was taken from guillaumegarcia13's fork, which added the
same block; the date handling here is our own, since that fork routes 7250
through parseDate and hits the problem described above.
@MaximBelov
MaximBelov force-pushed the feat/person-and-mto-ais branch from bb5b2d0 to cf91ca1 Compare August 13, 2026 06:09
@MaximBelov MaximBelov mentioned this pull request Aug 13, 2026
@MaximBelov
MaximBelov merged commit bd6b71d into master Aug 13, 2026
1 check passed
@MaximBelov
MaximBelov deleted the feat/person-and-mto-ais branch August 13, 2026 10:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant