Check-Digit Collisions in the New NHI Implementation

In Uncategorised by Jayden MacRae

The new NHI format has been implemented to further extend the NHI range as we were previously running out of NHIs. The new format is:

AAA00AA

Where A is an alpha character between A and Z, excluding the letters I and O and 0 is a number ranging from 0-9. The final alpha is the check digit.

The previous NHI had a collision issue, where the check-digit for any given transposition of an alpha character could result in a check digit with the same value. This was a result of the check digit having a value range of only 10 digits (0-9) with an input range of 24 characters as positions 1-3.

The new NHI however has a check digit which can be 24 values in length.

There appears however to be a significant flaw in the implementation. The new algorithm uses a modulus 24 operation but has used the same second factor values at each position of the NHI. The original second factor values are now factors of the modulus, which results in significant numbers of collisions. This issue didn’t arise in the old NHI algorithm as the modulus was a prime number.

An example is shown below, showing all combinations of the NHI ZAD96LT, changing the second letter:

NHICheck Digit
ZAD96LT
ZBD96LM
ZCD96LF
ZDD96LZ
ZED96LT
ZFD96LM
ZGD96LF
ZHD96LZ
ZJD96LT
ZKD96LM
ZLD96LF
ZMD96LZ
ZND96LT
ZPD96LM
ZQD96LF
ZRD96LZ
ZSD96LT
ZTD96LM
ZUD96LF
ZVD96LZ
ZWD96LT
ZXD96LM
ZYD96LF
ZZD96LZ

You can see the check digit repeats every 4 iterations. This means that each letter at position 2 has 5 different characters which would be transposed and the check algorithm would not detect as issue. Compared to the old NHI algorithm, which 11 characters had only one other letter which could be transposed without detection and 2 characters which had 2 others which wouldn’t be detected by a transposition.

Because the second factors of 7 and 5 are not factors of the modulus, this issue with the new NHI only affects transposition at positions 2,4,5 and 6 of the NHI.

This issue could be avoided by either changing the modulus to a number which does not have the existing second factors as factors (e.g. modulus 23) or by keeping modulus 24 while changing the second factors (e.g. using 14,13,10,7,5 as the second factors.

These would look like:

NHIMod 23Mod 24 + New Facs
ZAD96LTV
ZBD96LEG
ZCD96LQT
ZDD96LBE
ZED96LMR
ZFD96LXC
ZGD96LJP
ZHD96LUA
ZJD96LFM
ZKD96LRY
ZLD96LCK
ZMD96LNW
ZND96LYH
ZPD96LKU
ZQD96LVF
ZRD96LGS
ZSD96LSD
ZTD96LDQ
ZUD96LPB
ZVD96LAN
ZWD96LLZ
ZXD96LWL
ZYD96LHX
ZZD96LTJ

You can see that the modulus 23 solution still has a single collision (at ZAD96L and ZZD96L), but this would be a significant improvement on the prior collision issue. The use of modulus 24 but with second factors which are not factors of 24 (14,13,11,10,7,5) has no collisions and fully solves the issue.

Hopefully Te Whatu Ora are able to change this before the new NHI implementation goes live in 2025. If not, then we may have to be exceedingly vigilant with NHI protocols when any manual entry of NHI is done.