NHI Number

From Wikipedia, the free encyclopedia
Jump to navigation Jump to search

The National Health Index (NHI) number is the unique person identifier used within the New Zealand health system. It is technically not a number but rather an alphanumeric identifier consisting of 7 characters, with three letters and four numbers. It is often referred to as the NHI, although care must be taken when using this abbreviated term, because the NHI can also refer to the national collection of health care user demographic data (of which the NHI Number is the unique identifier).

The NHI Number, as part of the NHI was established in 1993.[1]

Usage[edit]

Primarily the NHI is used to identify individuals uniquely within the New Zealand health system,[1][2] especially in electronic systems. An example of this is its use to alert health care providers using the Medical Warnings System (MWS) of risks associated with medical decision-making for specific patients.

Format[edit]

An NHI number has a specific format. It is 7 characters in length and contains a check digit. This format consists of 3 alphabetic characters being in the range of A-Z, excluding I and O, and 4 numeric characters being in the range 0-9. The 4th numeric character is the check digit. The assignment of the first 6 characters is arbitrary and bears no relationship to the individual to whom it is assigned.

The NHI Number is most often represented with the alphabetic characters upper case.

NHI Numbers are often referred to as being valid or invalid. Any NHI Number that does not fit the correct format or that has an incorrect check digit is referred to as invalid. Usually reference to an NHI Number being valid or not does not indicate that it is correctly associated with the right individual. As the identifier is arbitrary there is no way to do this based solely on the identifier itself.

By 2025 the NHI system will have exhausted all of the NHI numbers that are available. In 2019 a revised standard introduced a new format of 3 alphabetic characters being in the range of A-Z, excluding I and O, 2 numeric characters being in the range 0-9, one alphabetic character in the range of A-Z, excluding I and O followed by a check alphabetic character in the range of A-Z, excluding I and O.

The new format will be available for allocation July 2022. The two formats will co-exist indefinitely, and all administrative and clinical systems will need to support them both.

All NHI numbers starting with Z are reserved for test purposes.[3]

Duplicates[edit]

When it has been identified that an individual has been assigned more than one NHI Number, one is deemed to be the primary identifier. This is usually done by ranking all assigned numbers in alpha-numeric order and choosing the first one as the primary.

All other NHI Numbers for the individual within the NHI are then linked to the primary one.

Check digit[edit]

There are two variants of the check digit algorithm to allow for the old NHI number format having a numeric check digit while the new format has an alphabetic check character.

For the new format, each alphabetic character is given a numeric value equal to its ordinal position within a version of the alphabet that omits the letters I and O. The ordinal range is 1–24. This gives A=1 and Z=24, for example. Each numeric character is used with its face value 0–9 in the calculation.

Each character’s equivalent numeric value is then multiplied by its reverse ordinal position within the NHI number. The first value is multiplied by 7, the second by 6, the third by 5, the fourth by 4, the fifth by 3 and the sixth by 2. The sum of the six products is calculated. The calculated sum modulo 24 is subtracted from 24 to give an index number. If the index number is zero, then the NHI number is invalid and cannot be used.

For the old format, the NHI Number contains a check digit. The algorithm for generating the digit is described below:

Each alpha character is given a numeric representation equivalent to its ordinal position within the alphabet, starting at A through to Z. The letters I and O are omitted making the ordinal range 1 - 24.

Each alpha character's numeric representation is multiplied by the inverse of its ordinal position within the NHI Number. The first value is multiplied by 7, the second by 6 and so on.

The first 3 numeric characters are multiplied by the inverse of their ordinal position also.

The sum of these multiplications modulus 11 subtracted from 11 is taken as the check digit (a result of 10 is translated to 0).

This scheme is similar to the ISBN check digit scheme.

PHP code to calculate NHI validation for the old format[edit]

/**
 * @param  $nhi_number The NHI number to validate
 * @return bool        True if valid, false if not valid
 * @author             scott.quinlan[at]gmail.com
 */
function validateNHINumber_old(string $nhi_number) : bool
{
    // Inititial check of the format
    if (!preg_match('/^([a-zA-Z]){3}([0-9]){4}?$/', $nhi_number)) {
        return false;
    }

    // Split string in array
    $chars = preg_split('//', strtolower($nhi_number), -1, PREG_SPLIT_NO_EMPTY);
    $sum = 0;

    // Iterate through the first six characters, ignore the 7th being as it's the check digit
    for ($i = 0; $i < 6; $i++) {
        $char = $chars[$i];

        // The first three alpha characters are given a numeric representation equivalent
        // to its ordinal position within the alphabet, starting at A through to Z. The
        // letters I and O are omitted making the ordinal range 1 - 24.
        if ($i < 3) {
            $ascii = ord($chars[$i]);

            if ($ascii > 105) {
                if ($ascii > 111) {
                    $ascii -= 2;
                } else {
                    $ascii -= 1;
                }
            }

            $char = $ascii - 96;
        }

        // Each alpha character's numeric representation is multiplied by the
        // inverse of its ordinal position within the NHI Number. The first
        // value is multiplied by 7, the second by 6 and so on.
        $sum += ((int)$char * (7 - $i));
    }

    // Apply modulus 11 to create a checksum.
    $checksum = (float)fmod($sum, 11);
    $checkdigit = 11 - $checksum;

    // If checksum is zero then the NHI number is incorrect
    if ($checksum == 0) {
        return false;
    }

    // If check digit equals 10 convert to zero
    if ((int)$checkdigit == 10) {
        $checkdigit = 0;
    }

    // Fourth number must be equal to check digit for a valid NHI number
    return ((int)$chars[6] == $checkdigit);
}

echo (int)validateNHINumber_old('DAB8233'); // 0 (invalid)
echo (int)validateNHINumber_old('CGC2720'); // 1 (valid)
echo (int)validateNHINumber_old('EPT6335'); // 1 (valid)

References[edit]

  1. ^ a b New Zealand Health Information Service. National Health Index (NHI). Retrieved 13 June 2007.
  2. ^ New Zealand Health Information ServiceNHI Number. Retrieved 13 June 2007.
  3. ^ Ministry of Health. "HISO 10046:2019 Consumer Health Identity Standard". Ministry of Health. Retrieved 15 August 2020.

External links[edit]