- Notifications
You must be signed in to change notification settings - Fork0
James-Ansley/pkl-nhi
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
A function to check strings against the New Zealand Ministry of Health NHIValidation Routine.Supports the old and new NHI number formats specified inHISO 10046:2023.
Add the following to your PklProject:
dependencies { ["nhi"] {uri ="package://pkg.pkl-lang.org/github.com/James-Ansley/pkl-nhi/nhi@0.0.2" }}
Use thenhi.isValid
function:
import"@nhi/nhi.pkl"typealiasNhi =String(nhi.isValid(this))myOtherValidNhi:Nhi="ZAC5361"// worksmyOtherInvalidNhi:Nhi="ZZZ0044"// fails
Checks are case-insensitive.
Note: This does not check that the NHI number has beenassigned toa person, it merely checks the NHI is consistent with the HISO 10046:2023standard.
NHI numbers that begin withZ
are reserved for testing.If you wish to exclude these values, you will need to manually check for aZ
prefix:
import"@nhi/nhi.pkl"typealiasNhi =String(nhi.isValid(this),!startsWith("Z"),!startsWith("z"))myNhi1:Nhi="ABC12AY"// worksmyNhi2:Nhi="ZAC5361"// fails
Note: This check does not mean that the NHI number has beenassigned toa person, it just means that the NHI value is not reserved for testing.
About
NHI validator in Pkl