Driver licence endorsements

samuel.mortlock
21 March 2024

Outputs:

SQL: [IDI_Community].[drv_dlr_endorsement].[dlr_endorsement_202603]
SAS: libname cm_dlr_endorsement dsn=IDI_community_srvprd schema=drv_dlr_endorsement; run ;
How to access a code module in the Data Lab: Read here

Inputs:

Dependency Dependency Type
[IDI_Clean_202603].[nzta_clean].[drivers_licence_register] Source

Context

This module creates a table of driver licence endorsement spells by the type and status of endorsement. It is sourced from Waka Kotahi NZ Transport Agency’s wider register of driver licences, which also includes information specific to endorsements.

Business Concepts

Endorsements are required to operate certain types of vehicles and services. There are nine types of driver license endorsements each of which is also known by a one letter code - passenger (P), vehicle recovery (V), driving instructor (I), testing officer (O), dangerous goods (D), forklift (F), roller (R), tracks (T) and wheels (W).

Endorsements are usually gained by completing an appropriate course. Certain endorsements - for example, driving instructor (I), driver testing officer (O), commercial passenger (P) and vehicle recovery (V) - also require a police background check.

Endorsements may also require a medical certificate (unless already provided to Waka Kotahi in the last five years).

Licence endorsements

The ten types of endorsement are detailed below.

  1. Passenger (P) to drive paying passengers or a large passenger service vehicle (e.g., taxi or bus), you need a P endorsement.

  2. Vehicle Recovery (V) to operate a vehicle recovery service - for example, tow truck and car transporter drivers - you need a V endorsement.

  3. Driver Instructor (I) to teach people to drive for business or payment, you need an I endorsement.

  4. Testing officer (O) to conduct practical driving tests, you need an O endorsement, and must be employed by - or contracted to - Waka Kotahi NZ Transport Agency, its testing agent VTNZ, or the NZ Defence Force.

  5. Forklift (F) to drive a forklift on the road, you need an F endorsement and a weight-appropriate licence class. An F endorsement for a class 1 licence, covers forklifts with a weight of up to 18,000kg when loaded; and for a class 2 licence, covers forklifts over 18,000kgs when loaded.

  6. Dangerous Goods (D) to drive a vehicle or vehicle combination to transport dangerous goods, you need a D endorsement.

  7. Special-type vehicles (R T W) to drive a special-type vehicle on the road, you need an appropriate endorsement.

  8. Roller (R) to drive vehicles on rollers.

  9. Tracks (T) to drive vehicles on self-laying tracks.

  10. Wheels (W) to drive special-type vehicles on wheels as used in mining or roadworks (excluding forklifts, tractors, trade vehicles etc.).

Endorsement Status:

Each endorsement type has a status. For example, a specific endorsement type may have a status of expired. If a licence holder is disqualified, then all their endorsements will also have a status of requalify at the end of the disqualification period.

Current status. Endorsement holders are eligible to operate certain vehicle types and services provided they have a current licence status.

Non-current statuses. For the following statuses, the endorsement type is not current.

Cancelled Status. The endorsement type has been cancelled.

Waka Kotahi Open Data Comparison

To verify the accuracy of IDI sourced endorsement spell data, we compared the number of endorsement holders (via the IDI) to numbers released by NZ Transport Agency Waka Kotahi.

End of year comparisons (from 2008 to 2023) between these two sources showed a match of over 98%.

Business history

Date Change
1-Oct-12 Automatic renewal where an application for an endorsement
also meets requirements for renewal of a licence class.
1-Jun-13 Class 2 licence holders no longer require a special-type
endorsement to drive agricultural vehicles.
1-Oct-17 Introduction of two separate Passenger (P) endorsement
service licence (large and small), whereby no course or practical
test is required for small P endorsements (no change to large P endorsement)
10-Apr-20 Endorsements set to expire from 1 March 2020 were temporarily
extended for up to 6 months under the COVID-19 Response.
1-Oct-23 Changes in licencing fees including endorsements.

References

1.Getting an endorsement Waka Kotahi NZ Transport Agency 2024.
2.Driving licencing fees Waka Kotahi NZ Transport Agency 2024.

Community of Interest

Who Agency Involvement
Sam Mortlock MSD Initial draft of the code. Module Steward
Marc de Boer MSD Encyclopaedic & Experiential Documentation review
Boah Rasmussen Waka Kotahi Preparation of table of NZTA driver licence register status
Tom Zhou Waka Kotahi Preparation of table of NZTA driver licence register status
Linda Martis Nicholson Consulting Module coder
Oliver Robertson MSD Driver licence code review and analysis

Key Business Rules

We calculate the end date of an endorsement status as one day before the start of the next status.

Parameters

The following parameters should be supplied to this module to run it in the database:

  1. {targetdb}: The SQL database on which the spell datasets are to be created.
  2. {targetschema}: The project schema under the target database into which the spell datasets are to be created.
  3. {projprefix}: A (short) prefix that enables you to identify the spell dataset easily in the schema, and prevent overwriting any existing datasets that have the same name.

Variable Descriptions

The business key for this spell table is one row per snz_uid, endorsement type, endorsement status, and spell start.

Aspect Variables Description
Entity snz_uid The unique STATSNZ person identifier for the person.
snz_nzta_uid The unique NZTA person identifier for the person.
Source data_source nzta_driver_licence_register
Period spell_start The start date for the endorsement status specific to an endorsement type.
spell_end The imputed end date for the endorsement status. For the current endorsement status this end date is set to 31 December 9999.
Event information nzta_dlr_endorsementtype_text The type of endorsement a person holds. There are nine types: passenger, forklift, dangerous goods, roller, wheels, track, instructor, testing officer
nzta_dlr_endorsementstatus_text Endorsement status determining whether a person is eligible for endorsement

Module Version & Change History

Date Version Comments
4 March 2024 Initial version based on specifications from Commissioning document.

DROP VIEW IF EXISTS [(targ etschema)].[(proj prefix)_driver _license_e ndorsemen ts];
GO
/* This creates a table all demographic information */
CREA TE VI EW [(ta r ge ts chema)].[(pr ojp refix)_driver lic ense endorsements] AS

Code

 :setvar targetdb "{targetdb}"
:setvar targetschema "{targetschema}"
:setvar projprefix "{projprefix}"
:setvar idicleanversion "{idicleanversion}"

/* Clear view */

DROP TABLE IF EXISTS #new_temp;
WITH nz_licences AS(
    SELECT [snz_uid]
        , [snz_nzta_uid]
        , [nzta_dlr_endorsement_type_text]
        , [nzta_dlr_endorsement_start_date]
        , [nzta_dlr_endorsement_expiry_date]
        , [nzta_dlr_endorsement_status_text]
        , [nzta_dlr_endorsement_from_date]
        , CASE 
			WHEN nzta_dlr_endorsement_status_text = 'CURRENT' THEN 1 ELSE 0 END AS [current_indicator]
        , [nzta_dlr_endorsement_from_date] AS spell_start
        , [nzta_dlr_endorsement_expiry_date] AS expiry_date
    FROM [$(idicleanversion)].[nzta_clean].[drivers_licence_register]
    WHERE nzta_dlr_endorsement_type_text IS NOT NULL
    AND nzta_dlr_endorsement_start_date IS NOT NULL
)
    , table1 AS(
    SELECT *
        , ROW_NUMBER() OVER (
			PARTITION BY nzta_dlr_endorsement_type_text, snz_uid, spell_start
			ORDER BY nzta_dlr_endorsement_type_text ASC, snz_uid ASC, spell_start DESC
		) AS seqnum
    FROM nz_licences
)
    , licences_dsc AS(
    SELECT *
    FROM table1
    WHERE seqnum = 1
)
    , licences_withlag_dsc1 AS(
    SELECT *
        , LAG(■■■■■■■■■■■■ OVER(
			ORDER BY nzta_dlr_endorsement_type_text ASC, snz_uid ASC, spell_start DESC
		  ) AS next_snz_uid
        , LAG(DATEADD(DAY, -1, spell_start),1) OVER(
			ORDER BY nzta_dlr_endorsement_type_text ASC, snz_uid ASC, spell_start DESC
		 ) AS spell_end1
    FROM licences_dsc
)
    , licences_withlag_dsc AS(
    SELECT *
        , CASE
			WHEN [snz_uid] != [next_snz_uid] THEN '9999-12-01'
			WHEN [snz_uid] = [next_snz_uid] THEN spell_end1 END AS spell_end
    FROM licences_withlag_dsc1
)
SELECT [snz_uid]
    , [snz_nzta_uid]
    , [spell_start]
    , [spell_end]
    , [nzta_dlr_endorsement_type_text]
    , [nzta_dlr_endorsement_status_text]
INTO #new_temp
FROM licences_withlag_dsc;

SELECT * 

INTO [$(targetdb)].[$(targetschema)].[$(projprefix)_driver_license_endorsements]

FROM #new_temp
 ;
GO