{
  "title": "Test Result Cat CPC Schema",
  "type": "object",
  "definitions": {
    "testData": {
      "additionalProperties": false,
      "description": "Data associated with the test",
      "properties": {
        "combination": {
          "$ref": "#/definitions/combinationCodes"
        },
        "question1": {
          "$ref": "#/definitions/question"
        },
        "question2": {
          "$ref": "#/definitions/question"
        },
        "question3": {
          "$ref": "#/definitions/question"
        },
        "question4": {
          "$ref": "#/definitions/question"
        },
        "question5": {
          "$ref": "#/definitions/question5"
        },
        "totalPercent": {
          "description": "Overall score for questions",
          "type": "number"
        }
      },
      "required": [
        "question1",
        "question2",
        "question3",
        "question4",
        "question5",
        "totalPercent"
      ]
    },
    "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"
    },
    "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"
        },
        "candidateDeclarationSigned": {
          "description": "Whether or not the candidate signature had been recorded for delegated tests",
          "type": "boolean"
        }
      },
      "required": [
        "insuranceDeclarationAccepted",
        "residencyDeclarationAccepted",
        "preTestSignature"
      ]
    },
    "accompaniment": {
      "description": "Indicators for anybody else overseeing the test",
      "type": "object",
      "properties": {
        "supervisor": {
          "description": "Indicates whether a DVSA supervisor was present during the test",
          "type": "boolean"
        },
        "interpreter": {
          "description": "Indicates whether an interpreter was present during the test",
          "type": "boolean"
        }
      },
      "additionalProperties": false
    },
    "answer": {
      "description": "Answers to the question",
      "additionalProperties": false,
      "properties": {
        "selected": {
          "type": "boolean"
        },
        "label": {
          "type": "string"
        }
      },
      "required": [
        "label",
        "selected"
      ]
    },
    "question": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "questionCode": {
          "description": "Short code for Question",
          "type": "string"
        },
        "title": {
          "description": "Question description",
          "type": "string"
        },
        "subtitle": {
          "description": "Question sub-description",
          "type": "string"
        },
        "additionalItems": {
          "description": "Additional questions that might be asked",
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "answer1": {
          "$ref": "#/definitions/answer"
        },
        "answer2": {
          "$ref": "#/definitions/answer"
        },
        "answer3": {
          "$ref": "#/definitions/answer"
        },
        "answer4": {
          "$ref": "#/definitions/answer"
        },
        "score": {
          "description": "Score in percent",
          "type": "number"
        }
      }
    },
    "question5": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "questionCode": {
          "description": "Short code for Question",
          "type": "string"
        },
        "title": {
          "description": "Question description",
          "type": "string"
        },
        "subtitle": {
          "description": "Question sub-description",
          "type": "string"
        },
        "additionalItems": {
          "description": "Additional questions that might be asked",
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "answer1": {
          "$ref": "#/definitions/answer"
        },
        "answer2": {
          "$ref": "#/definitions/answer"
        },
        "answer3": {
          "$ref": "#/definitions/answer"
        },
        "answer4": {
          "$ref": "#/definitions/answer"
        },
        "answer5": {
          "$ref": "#/definitions/answer"
        },
        "answer6": {
          "$ref": "#/definitions/answer"
        },
        "answer7": {
          "$ref": "#/definitions/answer"
        },
        "answer8": {
          "$ref": "#/definitions/answer"
        },
        "answer9": {
          "$ref": "#/definitions/answer"
        },
        "answer10": {
          "$ref": "#/definitions/answer"
        },
        "score": {
          "description": "Score in percent",
          "type": "number"
        }
      }
    },
    "gearboxCategory": {
      "$ref": "../common/index.json#/definitions/gearboxCategory"
    },
    "postTestDeclarations": {
      "$ref": "../common/index.json#/definitions/postTestDeclarations"
    },
    "identification": {
      "$ref": "../common/index.json#/definitions/identification"
    },
    "testSummary": {
      "description": "Recording of other characteristics of the test",
      "type": "object",
      "properties": {
        "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"
        },
        "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"
        },
        "assessmentReport": {
          "description": "Assessment report for the test",
          "type": "string"
        }
      },
      "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"
    },
    "configuration": {
      "description": "The vehicle configuration",
      "type": "string",
      "enum": [
        "Rigid",
        "Articulated",
        "Drawbar"
      ]
    },
    "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"
        },
        "configuration": {
          "$ref": "#/definitions/configuration"
        }
      },
      "additionalProperties": false
    },
    "passCompletion": {
      "description": "Finalisation of a successful test outcome",
      "type": "object",
      "properties": {
        "passCertificateNumber": {
          "description": "The PCN issued to the candidate",
          "type": "string",
          "maxLength": 8,
          "minLength": 8
        }
      },
      "additionalProperties": false,
      "required": [
        "passCertificateNumber"
      ]
    },
    "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
    },
    "combinationCodes": {
      "description": "Short codes for the CPC questions",
      "type": "string",
      "enum": [
        "LGV1",
        "LGV2",
        "LGV3",
        "LGV4",
        "LGV5",
        "LGV6",
        "LGV7",
        "LGV8",
        "PCV1",
        "PCV2",
        "PCV3",
        "PCV4",
        "PCV5",
        "PCV6",
        "PCV7",
        "PCV8"
      ]
    }
  },
  "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"
    },
    "delegatedTest": {
      "description": "Whether the test was completed by a delegated examiner or not",
      "type": "boolean"
    },
    "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"
  ]
}
