NHI

RepositoryLicenseHex

A function to check strings against the New Zealand Ministry of Health NHI Validation Routine. Supports the old and new NHI number formats specified in HISO 10046:2024.

Install

def deps do
  [
    {:nhi, "~> 0.0.1"}
  ]
end

For the other versions of this library, see:

Usage

New format NHI values:

iex> Nhi.valid?("ABC12DS")
true
iex> Nhi.valid?("AAA11AU")
true

Old format NHI values:

iex> Nhi.valid?("AAA1116")
true
iex> Nhi.valid?("BBB2221")
true

By default, test NHI values (starting with 'Z') are rejected:

iex> Nhi.valid?("ZZZ00AC")
false

Test values can be allowed with the allow_test_values flag:

iex> Nhi.valid?("ZZZ00AC", allow_test_values: true)
true

See Also