README.md
# NHI
[](https://codeberg.org/jamesansley/nhi)
[](https://codeberg.org/jamesansley/nhi/src/branch/main/LICENSE)
[](https://hex.pm/packages/nhi)
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](https://www.tewhatuora.govt.nz/publications/hiso-100462024-consumer-health-identity-standard/).
## Install
```elixir
def deps do
[
{:nhi, "~> 0.0.1"}
]
end
```
For the other versions of this library, see:
- [nhi on PyPi](https://pypi.org/project/python-nhi/)
- [nhi on JSR](https://jsr.io/@ansley/nhi)
- [nhi on Crates](https://crates.io/crates/nhi)
- [nhi with Pkl](https://codeberg.org/jamesansley/nhi/src/branch/main/pkl)
## Usage
New format NHI values:
```elixir
iex> Nhi.valid?("ABC12DS")
true
iex> Nhi.valid?("AAA11AU")
true
```
Old format NHI values:
```elixir
iex> Nhi.valid?("AAA1116")
true
iex> Nhi.valid?("BBB2221")
true
```
By default, test NHI values (starting with 'Z') are rejected:
```elixir
iex> Nhi.valid?("ZZZ00AC")
false
```
Test values can be allowed with the `allow_test_values` flag:
```elixir
iex> Nhi.valid?("ZZZ00AC", allow_test_values: true)
true
```
## See Also
- https://www.tewhatuora.govt.nz/publications/hiso-100462024-consumer-health-identity-standard/