NHI Validation

Here is a National Health Index (NHI) validator and generator that I created. NHIs are healthcare identifiers used in New Zealand[1][2][3].

NHI Validator
Generate NHIs

Generate random NHIs

    • NHI's uses the letters A-Z without I or O.
    • NHI's start with three letters and end with four numbers.
    • The last digit is a checksum.
    • NHI's are assigned randomly. I believe hospitals have distinct sets ready to be assigned.
    • Its possible for somebody to have multiple NHIs (first alphabetically is the primary).

    The current Id. structure only allows for around 13.8 million NHI's. With a population of around 5 million in 2019 and the possibility of a single person being associated to multiple Id.s, I suspect NHIs in their current form wont be around very long.


    (last checked 2023-06-06)

    1. https://en.wikipedia.org/wiki/NHI_Number
    2. https://www.health.govt.nz/our-work/health-identity/national-health-index
    3. http://www.midcentraldhb.govt.nz/PatientsandVisitors/GeneralInformation/Pages/NHI.aspx

    [EDIT]: Thanks to Chris W for pointing out a bug in my previous implementation. If the checksum is a '0' before being subtracted from 11, the NHI number is deemed to be invalid. This is now fixed in the generator.

    Brisbane Webcam

    Brisbane Webcam

    Using an old phone (Nokia N900) I have set up a webcam to take a photo every 5 minutes during the day and upload it to my website. You can see the latest photo on: Webcam

    N900 set up as a webcam

    I have set my computers desktop background to sync with the latest photo too. So far I have a years worth of images and have made a few time-lapses. Here is one over a couple of days:

    Timelapse from the webcam

    Webcam Security System

    A while ago I set up an old webcam / Raspberry Pi to serve as a security camera. Using Motion[1], its easy to set up a system that will record any movement and can be manually enabled or set to run on a simple schedule such as while I am away at work.

    Eventually I made the system a bit smarter to automatically turn on when I leave home and turn off as soon as I get back. Added to that, if anything moves while I am out, I get a message with a photo sent to my phone.

    For fun, I also added an AI to my messaging system so if I get bored I can have a chat or ask it to do some pre-programmed tasks (such as shutting down systems on the network, taking a photo or changing its settings).

    The whole system is built using:

    Python Process

    The heart of the system is written in Python and is set to run as a systemd process. It mostly sleeps and wakes up every so often (~10 seconds) to check for new motion events or messages from telegram.

    Network presence detection

    It turns out that its not easy to detect the presence of iPhones on a network. In order to save power they can be come rather quiet and uncommunicative to network chatter.

    At first I tried to build something in Python but after it became clear it was no small task, I decided to delegate to a subprocess and run a system tool. Next, I went with a script using hping3[3] and arp tables. This still wasn’t fantastic so at the moment I am just using an nmap[2] ping. From my tests, this seems to work better than hping3 at finding the iPhone but my tests weren’t very scientific.


    I set up a database to log network presence and created a small PHP script to graph phones on the network. In the example below, you can see the blue graph for my phone, pink for my girlfriends and green shows when one of us are at home (and the system is turned off).





    Initially I build a messaging component using the free Telstra API[5]. This provided an API allowing me to send SMS messages to my phone when the system started up or movement was captured. I ripped this out when Telstra added more limits on the API and put more of a push to their priced model.


    After looking for a better way to do push notifications to my phone, I eventually settled on creating a Telegram[4] bot. This allayed my cost aversion, provided the push notification behaviour that I was after and opened up easier two way communication.


    I took an old copy of the A.L.I.C.E. AIML[6] bot and plugged it into my Telegram bot. Its hardly going to convince anybody in a Turing test but is still quite a bit of fun to chat to.

    Image Capture

    Motion provides a very easy to set up frame/video capture process on Linux. It has the ability to trigger actions when motion is detected but I have instead chosen to go with periodically polling its output for events and archiving captures.

    Capture from Motion


    (last checked 2019-02-16)

    1. https://motion-project.github.io/
    2. https://nmap.org/
    3. http://www.hping.org/
    4. https://telegram.org/
    5. https://dev.telstra.com/
    6. https://en.wikipedia.org/wiki/AIML