{
  "title": "Test Result Cat AM1 Schema",
  "type": "object",
  "definitions": {
    "singleFaultCompetencies": {
      "additionalProperties": false,
      "description": "Single fault competencies associated with the test",
      "properties": {
        "useOfStand": {
          "$ref": "#/definitions/singleFaultCompetencyOutcome"
        },
        "useOfStandComments": {
          "$ref": "#/definitions/faultComments"
        },
        "manualHandling": {
          "$ref": "#/definitions/singleFaultCompetencyOutcome"
        },
        "manualHandlingComments": {
          "$ref": "#/definitions/faultComments"
        },
        "slalom": {
          "$ref": "#/definitions/singleFaultCompetencyOutcome"
        },
        "slalomComments": {
          "$ref": "#/definitions/faultComments"
        },
        "slowControl": {
          "$ref": "#/definitions/singleFaultCompetencyOutcome"
        },
        "slowControlComments": {
          "$ref": "#/definitions/faultComments"
        },
        "uTurn": {
          "$ref": "#/definitions/singleFaultCompetencyOutcome"
        },
        "uTurnComments": {
          "$ref": "#/definitions/faultComments"
        },
        "controlledStop": {
          "$ref": "#/definitions/singleFaultCompetencyOutcome"
        },
        "controlledStopComments": {
          "$ref": "#/definitions/faultComments"
        },
        "emergencyStop": {
          "$ref": "#/definitions/singleFaultCompetencyOutcome"
        },
        "emergencyStopComments": {
          "$ref": "#/definitions/faultComments"
        },
        "avoidance": {
          "$ref": "#/definitions/singleFaultCompetencyOutcome"
        },
        "avoidanceComments": {
          "$ref": "#/definitions/faultComments"
        }
      }
    },
    "circuit": {
      "description": "Circuit completed (left or right)",
      "type": "string",
      "enum": [
        "Left",
        "Right"
      ]
    },
    "testData": {
      "additionalProperties": false,
      "description": "Data associated with the test",
      "properties": {
        "singleFaultCompetencies": {
          "$ref": "#/definitions/singleFaultCompetencies"
        },
        "emergencyStop": {
          "$ref": "#/definitions/emergencyStop"
        },
        "avoidance": {
          "$ref": "#/definitions/avoidance"
        },
        "drivingFaults": {
          "$ref": "#/definitions/drivingFaults"
        },
        "seriousFaults": {
          "$ref": "#/definitions/seriousFaults"
        },
        "dangerousFaults": {
          "$ref": "#/definitions/dangerousFaults"
        },
        "ETA": {
          "$ref": "#/definitions/ETA"
        }
      },
      "type": "object"
    },
    "singleFaultCompetencyOutcome": {
      "description": "The possible outcomes of any single fault competency",
      "enum": [
        "DF",
        "S",
        "D"
      ],
      "type": "string"
    },
    "SpeedRequirementCompetencyOutcome": {
      "description": "The possible outcomes of speed requirment fault competency",
      "enum": [
        "S"
      ],
      "type": "string"
    },
    "examiner": {
      "$ref": "../common/index.json#/definitions/examiner"
    },
    "testCentre": {
      "$ref": "../common/index.json#/definitions/testCentre"
    },
    "name": {
      "$ref": "../common/index.json#/definitions/name"
    },
    "address": {
      "$ref": "../common/index.json#/definitions/address"
    },
    "candidate": {
      "$ref": "../common/index.json#/definitions/candidate"
    },
    "applicationReference": {
      "$ref": "../common/index.json#/definitions/applicationReference"
    },
    "initiator": {
      "$ref": "../common/index.json#/definitions/initiator"
    },
    "testSlotAttributes": {
      "$ref": "../common/index.json#/definitions/testSlotAttributes"
    },
    "journalData": {
      "$ref": "../common/index.json#/definitions/journalData"
    },
    "signature": {
      "$ref": "../common/index.json#/definitions/signature"
    },
    "communicationMethod": {
      "$ref": "../common/index.json#/definitions/communicationMethod"
    },
    "conductedLanguage": {
      "$ref": "../common/index.json#/definitions/conductedLanguage"
    },
    "communicationPreferences": {
      "$ref": "../common/index.json#/definitions/communicationPreferences"
    },
    "preTestDeclarations": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "insuranceDeclarationAccepted": {
          "description": "Whether or not the candidate has declared that their test vehicle has a valid insurance policy",
          "type": "boolean"
        },
        "residencyDeclarationAccepted": {
          "description": "Whether or not the candidate has declared that they have lived in the UK for a period acceptable for taking the test",
          "type": "boolean"
        },
        "preTestSignature": {
          "$ref": "#/definitions/signature"
        },
        "DL196CBTCertNumber": {
          "$ref": "#/definitions/DL196CBTCertNumber"
        }
      },
      "required": [
        "insuranceDeclarationAccepted",
        "residencyDeclarationAccepted",
        "preTestSignature"
      ]
    },
    "accompaniment": {
      "$ref": "../common/index.json#/definitions/accompaniment"
    },
    "gearboxCategory": {
      "$ref": "../common/index.json#/definitions/gearboxCategory"
    },
    "drivingFaultCount": {
      "$ref": "../common/index.json#/definitions/drivingFaultCount"
    },
    "faultComments": {
      "$ref": "../common/index.json#/definitions/faultComments"
    },
    "drivingFaults": {
      "description": "The driving faults accumulated during the test",
      "type": "object",
      "properties": {
        "precautions": {
          "$ref": "#/definitions/drivingFaultCount"
        },
        "precautionsComments": {
          "$ref": "#/definitions/faultComments"
        },
        "moveOffSafety": {
          "$ref": "#/definitions/drivingFaultCount"
        },
        "moveOffSafetyComments": {
          "$ref": "#/definitions/faultComments"
        },
        "moveOffControl": {
          "$ref": "#/definitions/drivingFaultCount"
        },
        "moveOffControlComments": {
          "$ref": "#/definitions/faultComments"
        }
      },
      "additionalProperties": false
    },
    "seriousFaultIndicator": {
      "$ref": "../common/index.json#/definitions/seriousFaultIndicator"
    },
    "seriousFaults": {
      "description": "The serious faults accumulated during the test",
      "type": "object",
      "properties": {
        "precautions": {
          "$ref": "#/definitions/seriousFaultIndicator"
        },
        "precautionsComments": {
          "$ref": "#/definitions/faultComments"
        },
        "moveOffSafety": {
          "$ref": "#/definitions/seriousFaultIndicator"
        },
        "moveOffSafetyComments": {
          "$ref": "#/definitions/faultComments"
        },
        "moveOffControl": {
          "$ref": "#/definitions/seriousFaultIndicator"
        },
        "moveOffControlComments": {
          "$ref": "#/definitions/faultComments"
        }
      },
      "additionalProperties": false
    },
    "dangerousFaultIndicator": {
      "$ref": "../common/index.json#/definitions/dangerousFaultIndicator"
    },
    "dangerousFaults": {
      "description": "The dangerous faults accumulated during the test",
      "type": "object",
      "properties": {
        "precautions": {
          "$ref": "#/definitions/dangerousFaultIndicator"
        },
        "precautionsComments": {
          "$ref": "#/definitions/faultComments"
        },
        "moveOffSafety": {
          "$ref": "#/definitions/dangerousFaultIndicator"
        },
        "moveOffSafetyComments": {
          "$ref": "#/definitions/faultComments"
        },
        "moveOffControl": {
          "$ref": "#/definitions/dangerousFaultIndicator"
        },
        "moveOffControlComments": {
          "$ref": "#/definitions/faultComments"
        }
      },
      "additionalProperties": false
    },
    "postTestDeclarations": {
      "$ref": "../common/index.json#/definitions/postTestDeclarations"
    },
    "weatherConditions": {
      "$ref": "../common/index.json#/definitions/weatherConditions"
    },
    "identification": {
      "$ref": "../common/index.json#/definitions/identification"
    },
    "testSummary": {
      "description": "Recording of other characteristics of the test",
      "type": "object",
      "properties": {
        "routeNumber": {
          "description": "Number of the route that was taken during the test",
          "type": "integer",
          "const": 88
        },
        "trueLikenessToPhoto": {
          "description": "Physical appearance resembles a true likeness to provided ID",
          "type": "boolean"
        },
        "candidateDescription": {
          "description": "Physical description of the candidate",
          "type": "string",
          "maxLength": 1000
        },
        "debriefWitnessed": {
          "description": "Indicates whether anybody else (e.g. ADI) was present for the debrief",
          "type": "boolean"
        },
        "identification": {
          "$ref": "#/definitions/identification"
        },
        "weatherConditions": {
          "description": "Description of the type of weather encountered during the test",
          "type": "array",
          "items": {
            "$ref": "#/definitions/weatherConditions"
          }
        },
        "D255": {
          "description": "Indicates whether a D255 form needs to be completed",
          "type": "boolean"
        },
        "additionalInformation": {
          "description": "Any comments that the DE wants to record about the test",
          "type": "string"
        },
        "circuit": {
          "$ref": "#/definitions/circuit"
        }
      },
      "additionalProperties": false
    },
    "categoryCode": {
      "$ref": "../common/index.json#/definitions/categoryCode"
    },
    "activityCode": {
      "$ref": "../common/index.json#/definitions/activityCode"
    },
    "gender": {
      "$ref": "../common/index.json#/definitions/gender"
    },
    "rekeyReason": {
      "$ref": "../common/index.json#/definitions/rekeyReason"
    },
    "transfer": {
      "$ref": "../common/index.json#/definitions/transfer"
    },
    "ipadIssue": {
      "$ref": "../common/index.json#/definitions/ipadIssue"
    },
    "other": {
      "$ref": "../common/index.json#/definitions/other"
    },
    "vehicleDetails": {
      "description": "Details about the vehicle to be used for the test",
      "type": "object",
      "properties": {
        "registrationNumber": {
          "description": "The vehicle registration number",
          "type": "string",
          "maxLength": 7
        },
        "motStatus": {
          "description": "The mot status of the vehicle",
          "type": "string"
        },
        "motEvidenceProvided": {
          "description": "Marker stating if alternative MOT evidence was provided",
          "type": "boolean"
        },
        "motEvidence": {
          "description": "Alternative MOT evidence",
          "type": "string"
        },
        "make": {
          "description": "The make of the vehicle",
          "type": "string"
        },
        "model": {
          "description": "The model of the vehicle",
          "type": "string"
        },
        "testExpiryDate": {
          "description": "The test expiry date of the vehicle",
          "type": "string"
        },
        "previouslySearchedRegNumbers": {
          "description": "Previously searched for registration numbers",
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "gearboxCategory": {
          "$ref": "#/definitions/gearboxCategory"
        },
        "schoolBike": {
          "$ref": "#/definitions/schoolBike"
        }
      },
      "additionalProperties": false
    },
    "passCompletion": {
      "description": "Finalisation of a successful test outcome",
      "type": "object",
      "properties": {
        "passCertificateNumber": {
          "description": "The PCN issued to the candidate",
          "type": "string",
          "maxLength": 7,
          "minLength": 7
        }
      },
      "additionalProperties": false,
      "required": [
        "passCertificateNumber"
      ]
    },
    "DL196CBTCertNumber": {
      "description": "The number of the DL196 CBT certificate presented by the candidate",
      "type": "string"
    },
    "avoidance": {
      "description": "The outcome of avoidance tests",
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "firstAttempt": {
          "description": "The speed of the first attempt",
          "type": "integer"
        },
        "secondAttempt": {
          "description": "The speed of the second attempt",
          "type": "integer"
        },
        "outcome": {
          "$ref": "#/definitions/SpeedRequirementCompetencyOutcome"
        },
        "comments": {
          "$ref": "#/definitions/faultComments"
        }
      }
    },
    "emergencyStop": {
      "description": "The outcome of emergency stop tests",
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "firstAttempt": {
          "description": "The speed of the first attempt",
          "type": "integer"
        },
        "secondAttempt": {
          "description": "The speed of the second attempt",
          "type": "integer"
        },
        "outcome": {
          "$ref": "#/definitions/SpeedRequirementCompetencyOutcome"
        },
        "comments": {
          "$ref": "#/definitions/faultComments"
        }
      }
    },
    "ETA": {
      "$ref": "../common/index.json#/definitions/ETA"
    },
    "schoolBike": {
      "description": "Indicates whether the bike belongs to a driving school",
      "type": "boolean"
    },
    "businessName": {
      "description": "Name of the business the candidate relates to",
      "type": "string",
      "maxLength": 100
    },
    "businessTelephone": {
      "description": "Telephone number of the business the candidate relates to",
      "type": "string",
      "maxLength": 20
    }
  },
  "properties": {
    "version": {
      "description": "Version number",
      "type": "string"
    },
    "appVersion": {
      "description": "App version number",
      "type": "string"
    },
    "category": {
      "$ref": "#/definitions/categoryCode"
    },
    "journalData": {
      "$ref": "#/definitions/journalData"
    },
    "activityCode": {
      "$ref": "#/definitions/activityCode"
    },
    "communicationPreferences": {
      "$ref": "#/definitions/communicationPreferences"
    },
    "preTestDeclarations": {
      "$ref": "#/definitions/preTestDeclarations"
    },
    "accompaniment": {
      "$ref": "#/definitions/accompaniment"
    },
    "postTestDeclarations": {
      "$ref": "#/definitions/postTestDeclarations"
    },
    "testSummary": {
      "$ref": "#/definitions/testSummary"
    },
    "rekeyReason": {
      "$ref": "#/definitions/rekeyReason"
    },
    "rekey": {
      "description": "Whether the test was rekeyed or not",
      "type": "boolean"
    },
    "rekeyDate": {
      "description": "Date the test was rekeyed",
      "type": "string"
    },
    "changeMarker": {
      "description": "Whether the test was conducted by another examiner",
      "type": "boolean"
    },
    "examinerBooked": {
      "description": "The examiner who the test was booked to",
      "type": ["number", "string"]
    },
    "examinerConducted": {
      "description": "The examiner who conducted the test",
      "type": ["number", "string"]
    },
    "examinerKeyed": {
      "description": "The examiner who keyed the test into the iPad",
      "type": "number"
    },
    "passCompletion": {
      "$ref": "#/definitions/passCompletion"
    },
    "vehicleDetails": {
      "$ref": "#/definitions/vehicleDetails"
    },
    "userExitedApp": {
      "$ref": "../common/index.json#/definitions/userExitedApp"
    },
    "testData": {
      "$ref": "#/definitions/testData"
    }
  },
  "additionalProperties": false,
  "required": [
    "version",
    "category",
    "journalData",
    "activityCode",
    "rekey",
    "changeMarker",
    "examinerBooked",
    "examinerConducted",
    "examinerKeyed",
    "journalData"
  ]
}
