What is PRIMHD?

The New Zealand Ministry of Health specifies Primhd in the following way:

PRIMHD (pronounced ‘primed’) is a Ministry of Health single national mental health and addiction information collection of service activity and outcomes data for health consumers.

The data is collected from district health boards (DHBs) and non*governmental organisations (NGOs). It is stored in the PRIMHD datamart which is part of the Ministry’s national data warehouse.

How does PRIMHD relate to Paua?

Paua has the ability to extract a set of data in a format specified by the Ministry of Health.

The process proceeds as follows:

  • The generated extract is uploaded to a specified location on a Ministry of Health server.
  • The extract file is processed and if there are any problems or errors in the processing then a file containing these errors can be retrieved from another location on the Ministry server.
  • The error file can be opened in Paua to enable the errors to be viewed in a human readable form.
  • The errors can then be corrected and a new extract of Primhd data will contain the corrected data.

What Data is Extracted


Referral Discharge

The referral discharge record is the base client information


Activities consist of what Paua calls Client Contacts and Residence Nights and will be exported to Primhd with details such as date, contact type , duration of stay in residence etc. Obviously agencies that have no residential programme will not generate activities for residence nights.

Supplementary Consumer Records

These are represented in Paua by the Social Outcomes tab under the client details. Note that this tab is only present for clients who are in a programme that is exported to PRIMHD

Collection Occasions

Collection occasions consist of the data collected from ADOM forms (Alcohol and Drug Outcome Measure). Agencies that do not use ADOM will not generate any Collection Occasions.

Which clients are selected?

The Paua PRIMHD process selects clients in the following way:

Open and active clients at the end of the report period.
Activation date is present and prior to the end of the period. Exit date is either blank or after the end of the period.
Clients exited in the period.
Activation date is present. Exit date is in the report period.
Clients whose record was updated in the period.
The client updated_at audit date is in the period.
All Clients who have their Primhd Amendment Date or Primhd Deletion Date in the period.
These dates can be set by the user on the client page to force the inclusion of a client in the extract.

Having selected the clients according to the criteria above the extract process goes through and extracts all PRIMHD data for the lifetime of the client up until the end of the reporting period. This is so that all data gets sent with each PRIMHD extract rather than just trying to send updates which is more prone to synchronisation issues. The exception to the above is only if the PRIMHD Deletion date is set in which case only the core record data is sent with the PRIMHD DELETED_FLAG set to DELETED


Only clients in a programme that has a PRIMHD Team code set up will ever be selected.

Setting up PRIMHD

Connecting to MoH

In order to send PRIMHD extracts to the Moh/DHB you need to be able to connect to the MoH Connected Health Network through a VPN Provider. Details of the Connected Health Network including an application form to join the network can be found on the MoH website.

The application form contains a list of service providers and products. One example that has been successfully used by Paua users is Secure Me from Spark.

Setting up Paua for PRIMHD


First of all you need to enable PRIMHD in Paua under Optional Features in Preferences. Then you need to enter your PRIMHD Organisation ID in the corresponding field under General Preferences.

Setup PRIMHD Programmes

Probably only some of your Paua Programmes will be sending data to PRIMHD. You will know which ones. Each of these programmes need to be assigned a PRIMHD Team Code. These codes are assigned to your agency by MoH and there must be a one to one mapping between Paua Programmes and PRIMHD Team Codes. ie. you should not assign the same team code to multiple programmes.

Code Mappings

PRIMHD uses different codes to Paua and so Paua needs to be setup to enable the correct codes to be sent to PRIMHD. For most drop down lists this consists of prepending the corresponding PRIMHD code onto the beginning of the code description in Paua.

The Paua codes that need setting up are shown in the table below:

PRIMHD Code Paua Code Comment
REFERRAL_FROM Referral Source The first characters of the Paua referral_source code must consist of a valid Primhd Referral From code followed by a space and hyphen and then a description. eg. AE - Accident and Emergency
REFERRAL_TO Referral To The first characters of the Paua referral_to code must consist of a valid Primhd Referral To code followed by a space and hyphen and then a description. eg. GP - General practitioner
REFERRAL_END_CODE Referral End Code The first characters of the Paua referral_end_code must consist of a valid Primhd Referral end code followed by a space and hyphen and then a description. eg. DR - Ended routinely
ACTIVITY_TYPE Contact Type The first characters of the Paua contact_type code must consist of a valid Primhd Activity Type code followed by a space and hyphen and then a description. eg. T43 - Community support contact
ACTIVITY_SETTING Contact Location The first characters of the Paua contact_location code must consist of a valid Primhd Activity Setting code followed by a space and hyphen and then a description eg. CM - Community
REASON_FOR_COLLECTION Collection Point The first characters of the Paua contact_location code must consist of a valid Primhd Collection Point code followed by a space and hyphen and then a description. eg. RC18 - Treatment end routinely


The Collection Point code is only required to be set up if your agency uses ADOM forms and this data is to be extracted for PRIMHD.

Generating the extract file

You run the PRIMHD extract in the same way as many of the reports in Paua. Go to the Reports menu and pick Mental Health / PRIMHD. Select PRIMHD XML Report


There is also a report called PRIMHD (Contact) Report. This is a simpler report based on Client Contacts and designed for csv output. It has been superceded for PRIMHD by the full PRIMHD XML report but has been left in Paua as it can be a useful report even for agencies that do not use PRIMHD.

Select the start and end date for the report and click Submit Report The report will be run offline in the background and when ready will appear on the list of reports under Scheduled Report Output at the bottom of the reports page.

There can be up to three separate reports generated that appear in the list.

The main zip file

The most important of the three files is the main extract file which will be a .zip file. The name of the file will include the date of the extract and also the organisation id of the agency running the extract. The zip file contains one xml file for each client that has been selected by the report. The zip file is the file that has to be uploaded via your secure link to MoH.

Extract summary file

The summary .csv file is simply a summary listing how many records have been processed and also contains a list of potential errors. It is important to realise that Paua cannot foresee all possible errors that MoH may flag but the list provided in the summary report can be an aide to tidying up records before re*running the extract to minimise errors.

Residence summary file

In the same way as the main summary file the residence summary file is simply an aide to check the output more simply than trying to extract data from the actual .zip extract file. The residence summary simply lists all residences that have been extracted so that they can be checked against any other residence records that the agency may hold.

Dealing with errors

After uploading the .zip file to MoH you will receive back acknowledgment with information summarising the processing of your file. It is then up to you to work your way through those errors and attempt to rectify the issues before running another extract if recquired and uploading the new file.