Skip to main content

Guest blog post by Nigel Charman, a Service Lead for DevOps at Assurity.

Better Rules Hack

As part of Techweek 2018, Assurity hosted the Better Rules Hack (see the recent blog post on the Better Rules Hack - Wellington), to explore the ideas and practice of turning legislation into machine consumable 'digital rules' that can be reused and integrated across domains. Nigel Charman, from Assurity, joined a team who opted to figure out how organ donors could more easily discover what’s involved in making a gift to save lives.


I was lucky to be placed on a team with Brigette Metzler, Allen Geer and Jacob Oldfield, with Rachel Prosser helping us with ideation.

Our respective Friday nights had started with Brigette reading New Zealand legislation on the plane over from Tasmania, Allen and myself getting OpenFisca running and preparing the workspace at Assurity, and Jacob driving down from Taranaki.

On Saturday morning, we formed our team, got to know each other and discussed what we could work on. The concept we felt would make the most social good was creating a calculator for the Compensation for Live Organ Donations Act. This also met the objective of pulling in other Acts including the Income Tax Act and the KiwiSaver Act. Team OrganicCoders was born!

The team smiles for the camera.

Team OrganicCoders. Clockwise from left: Nigel Charman, Rachel Prosser, Allen Geer, Brigette Metzler, Jacob Oldfield

We then looked at architecture, with demos of Catalyst Cloud and the Regulation as a Platform (RaaP) and OpenFisca frameworks for writing legislation as code. Our team selected OpenFisca since it appeared to support mathematical calculations better.

While Allen spun up our infrastructure on the Catalyst Cloud, Jacob and I paired on back-end development using OpenFisca and Brigette started to get to grips with the legislation. We used Test Driven Development to develop the back-end code, starting off by writing a failing test then writing the minimum code to make it pass.

As we got our first test case to pass, Allen knocked up a UI (user interface) in no time. Jacob then worked with Allen to turn our test case into API calls from the UI. As we evolved the scope of the project, one test case at a time, the test cases proved valuable in demonstrating to Allen how to call the logic, saving a lot of debugging.

The Act seemed relatively straightforward to start with. Formulas such as (a / c) + (b / d) were deceptively complex once we got into the detail though, with changes of employment status, ACC compensation, self-employed and employee-shareholder earnings, Income Tax, Student Loans and KiwiSaver thrown into the mix.

Brigitte defined the terms in the legislation and resolving them as Linked Data by assigning unique identifiers. As a part of our project, we recognised that the act of coding the legislation was also creating a data model of sorts, so we took time to define the terms and reuse existing international vocabularies and standards where we could. Where we found something that had not been defined, we assigned a unique identifier to it. This allows others to also connect to this term, giving us a shared vocabulary, and a shared understanding of what’s common across different pieces of legislation.

By Saturday evening, we had a workable solution with a UI, a working calculator in the back-end and the start of a solution to Linked Data.

Screenshot of Save A Life website.

Brigette had also been tracking down prior donors for user research. Through a journalist friend, she discovered a Facebook group of donors and reached out for assistance.On Sunday morning Brigette interviewed Richie, who had donated a kidney to his father 5 years ago. At the time Richie had wanted to talk to other people about what it meant for them to donate and the success rate of living with only one kidney. How did it work? How would it change his current lifestyle? With Richie’s story, we were able to create a user journey that added a couple of steps before the roadmap published by the Ministry of Health (see page 2 of the Ministry of Health Compensation for Live Organ Donors information pack). We asked Richie what the compensation would have meant for him. He said he felt that providing compensation for loss of income would reduce the stress of what was already an intensely stressful situation. As an advocate with Kidney Health New Zealand, Richie suggested that the government needs to improve the visibility of the statistics about how often donations are happening and the success rate of the donations.

Allen and I then got a basic KiwiSaver implementation running, while Jacob took on the ambitious task of calculating basic Income Tax. We also linked to the Linked Data from the source code and UI. If we were to do this again, we might just have used the existing URI’s (Uniform Resource Identifier) where possible, but time and technical issues meant this had to be outside the scope of the Hackathon. We indicated where the connections were though, so this will make doing that work easier later on, for example:

  • Term name: NumberOfWeeks
  • UUID: organiccoders/brk:/1234/12a0780a-b516-44f1-bdb7-6ec4b6c3e174
  • Definition: number of weeks is (a) the number of full weeks plus any part week (expressed as a portion of a week), if the period is 1 week or more; and (b) a part week (expressed as a portion of a week), if the period is less than 1 week
  • Legislation: Part 1, Section 4
  • Narrower than:
  • Related: PeriodOfTime (altLabel:Period)
  • Note: Time event (ref DCAT temporal or CPSV ‘period of time’ An interval of time that is named or defined by its start and end dates.

By Sunday afternoon we had completed our video. From a team point of view, the weekend fully met our objectives. We all had fun and learnt heaps. We’re providing feedback to OpenFisca on a couple of issues we worked around. A fuller featured solution would definitely be feasible. This would be much simpler and avoid duplication if the Income Tax, KiwiSaver and related Acts were available as code. I hate to think how many private implementations there must be of these around NZ. Implementing legislation forced us to discuss issues such as “could there be 54 weeks in a year?” - if the definition of a week includes part-weeks, could you have a part-week at both ends of the year?

Well done to all of the teams who took part in the hackathon. Special thanks to the organisers - Craig Thomler, Nadia Webster, Robert O’Brien and Pia Andrews; to the coaches including Matti Schneider; and to the sponsors - Accenture, Assurity, Catalyst Cloud, Enspiral Dev Academy, Legal Hackers NZ and Victoria University of Wellington.

Utility links and page information