PHPackages                             webtorque/silverstripe-nhi-field - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. webtorque/silverstripe-nhi-field

ActiveSilverstripe-module[Database &amp; ORM](/categories/database)

webtorque/silverstripe-nhi-field
================================

Provide a NHI db field and NHI Form field to track NZ's "National Health Index" number.

v0.1.0(8y ago)03071MITPHPPHP &gt;= 5.4.0, &lt;=7.2

Since Sep 26Pushed 8y ago2 watchersCompare

[ Source](https://github.com/webtorque/silverstripe-nhi-field)[ Packagist](https://packagist.org/packages/webtorque/silverstripe-nhi-field)[ RSS](/packages/webtorque-silverstripe-nhi-field/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (2)Dependencies (4)Versions (3)Used By (0)

silverstripe-nhi-field
======================

[](#silverstripe-nhi-field)

A Silverstipe module to provide a NHI db field and NHI Form field to track NZ's "National Health Index" number.

[![Build Status](https://camo.githubusercontent.com/68bdc85e8e889e84a1b238724278064b154ad41e3e66eea442e9ca24b8bc7f66/68747470733a2f2f7472617669732d63692e6f72672f776562746f727175652f73696c7665727374726970652d6e68692d6669656c642e7376673f6272616e63683d646576)](https://travis-ci.org/webtorque/silverstripe-nhi-field)

Features
--------

[](#features)

- Custom DB field type
- Custom form field type with basic pattern validation and checksum validation.
- Consistently save NHI in all caps.

Requirements
------------

[](#requirements)

- PHP 5.4 or greater (tested with up to PHP 7.1)
- `silverstripe/framework:^3.0`
- `silverstripe/cms:^3.0`

Installation
------------

[](#installation)

```
composer require webtorque/silverstripe-nhi-field:^0.0
```

Usage
-----

[](#usage)

To specify a NHI db field on a DataObject:

```
class Patient extends DataObject {
    private static $db = [
        'NationalHealthIndex' => 'NHI',
    ];
}
```

The `NHI` field type is equivalent to `Varchar(7)`. When scaffolding a form, any NHI db field will autmatically use the `NHIField` form field instead of `TextField`.

Validating an NHI
-----------------

[](#validating-an-nhi)

Just use the `NHIField` in your form and validate your Form normally.

```
$nhiField = NHIField::create(
    $name = 'nhi',                      // required
    $title = 'National Health Index',   // optional
    $value = 'CGC2720',                 // optional
    $form = null,                       // optional
    $html5pattern = false               // optional, output an `html5` pattern attribute
);
```

`NHIField` is a simple extension of `TextField` with the following alteration:

- The `maxlength` is automatically set to 7.
- When setting the value of the field, it will automatically be converted to uppercase.
- The value is validated with a basic regex and with a [checksum as specified by the NHI standard](https://en.wikipedia.org/wiki/NHI_Number#Format).
- You can ouput an html5 `pattern` attribute with `$nhiField->setHtml5Pattern(true);`.

For testing purposes, checksum validation can be disabled by setting the `disable_checksum_validation` flag on the `NHIField` config.

```
if (Director::isDev()) {
    NHIField::config()->disable_checksum_validation = true;
}
```

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

2

Last Release

3151d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/08ee58ace40393521eae00decc0bc3b74d29291e9630e84b2831b38953aaca33?d=identicon)[webtorque](/maintainers/webtorque)

---

Top Contributors

[![maxime-rainville](https://avatars.githubusercontent.com/u/1168676?v=4)](https://github.com/maxime-rainville "maxime-rainville (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/webtorque-silverstripe-nhi-field/health.svg)

```
[![Health](https://phpackages.com/badges/webtorque-silverstripe-nhi-field/health.svg)](https://phpackages.com/packages/webtorque-silverstripe-nhi-field)
```

###  Alternatives

[patricknelson/silverstripe-migrations

SilverStripe Database Migration module. Facilitates atomic database migrations in SilverStripe 3.x

2126.7k](/packages/patricknelson-silverstripe-migrations)[brettt89/silverstripe-garbage-collector

SilverStripe Garbage Collector module

109.6k](/packages/brettt89-silverstripe-garbage-collector)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
