{
  "name": "RoutePlan",
  "description": "The plan of the work of one day in one area: a route per vehicle (the requests in order, with arrival and departure times) and the requests that did not fit. It keeps the result of route optimisation (VRP) software (routes and unassigned) as it is. What was actually driven can be recorded with Smart Data Models FleetVehicleOperation. At least one of planStatus, statusLabel is not null. Type https://datamodels.jp/ns/fieldservice/RoutePlan; @context https://datamodels.jp/context/fieldservice/v1.jsonld.",
  "strict": true,
  "schema": {
    "type": "object",
    "properties": {
      "provider": {
        "type": [
          "string",
          "null"
        ],
        "description": "The organisation that does the work (a municipality, a contractor) (a URI)"
      },
      "localGovernmentCode": {
        "type": [
          "string",
          "null"
        ],
        "pattern": "^\\d{6}$",
        "description": "Local government code (6 digits) of the municipality the plan is for"
      },
      "area": {
        "type": [
          "string",
          "null"
        ],
        "description": "The planning area, as the provider names it (not empty)"
      },
      "planDate": {
        "type": "string",
        "format": "date",
        "description": "The day the plan is for"
      },
      "planStatus": {
        "type": [
          "string",
          "null"
        ],
        "enum": [
          "draft",
          "confirmed",
          "in-progress",
          "completed",
          "cancelled",
          null
        ],
        "description": "State: draft, confirmed, in-progress, completed, cancelled. When no value fits, leave it out and write statusLabel"
      },
      "statusLabel": {
        "type": [
          "string",
          "null"
        ],
        "description": "The source system's own status name, unchanged. Required when the status is left out (not empty)"
      },
      "planner": {
        "type": [
          "string",
          "null"
        ],
        "description": "The software that made the plan, with its version (for example VROOM 1.14) (not empty)"
      },
      "computedAt": {
        "type": [
          "string",
          "null"
        ],
        "format": "date-time",
        "description": "When the plan was computed"
      },
      "vehicles": {
        "type": [
          "array",
          "null"
        ],
        "items": {
          "type": "string",
          "description": "(a URI)"
        },
        "minItems": 1,
        "description": "The vehicles of the plan: ServiceVehicles. Always an array in the key-values form, even with one (no duplicates)"
      },
      "serviceRequests": {
        "type": [
          "array",
          "null"
        ],
        "items": {
          "type": "string",
          "description": "(a URI)"
        },
        "minItems": 1,
        "description": "The requests planned, those left unassigned included: ServiceRequests. Always an array in the key-values form, even with one (no duplicates)"
      },
      "routes": {
        "type": "array",
        "items": {
          "type": "object",
          "properties": {
            "vehicle": {
              "type": "string",
              "description": "(a URI)"
            },
            "crew": {
              "type": [
                "string",
                "null"
              ],
              "description": "(a URI)"
            },
            "start": {
              "type": [
                "string",
                "null"
              ],
              "format": "date-time"
            },
            "end": {
              "type": [
                "string",
                "null"
              ],
              "format": "date-time"
            },
            "distance": {
              "type": [
                "number",
                "null"
              ],
              "description": "(minimum 0)"
            },
            "duration": {
              "type": [
                "string",
                "null"
              ],
              "description": "(must match the pattern ^P(?!$)(\\d+D)?(T(?=\\d)(\\d+H)?(\\d+M)?(\\d+(\\.\\d+)?S)?)?$)"
            },
            "load": {
              "type": [
                "array",
                "null"
              ],
              "items": {
                "type": "number",
                "description": "(minimum 0)"
              },
              "minItems": 1
            },
            "stops": {
              "type": "array",
              "items": {
                "type": "object",
                "properties": {
                  "kind": {
                    "type": "string",
                    "enum": [
                      "start",
                      "job",
                      "break",
                      "end"
                    ]
                  },
                  "request": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "(a URI)"
                  },
                  "position": {
                    "type": [
                      "array",
                      "null"
                    ],
                    "items": {
                      "type": "number"
                    },
                    "description": "(at least 2 items; at most 2 items)"
                  },
                  "arrival": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "format": "date-time"
                  },
                  "departure": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "format": "date-time"
                  },
                  "load": {
                    "type": [
                      "array",
                      "null"
                    ],
                    "items": {
                      "type": "number",
                      "description": "(minimum 0)"
                    },
                    "minItems": 1
                  }
                },
                "required": [
                  "kind",
                  "request",
                  "position",
                  "arrival",
                  "departure",
                  "load"
                ],
                "additionalProperties": false
              },
              "minItems": 1
            }
          },
          "required": [
            "vehicle",
            "crew",
            "start",
            "end",
            "distance",
            "duration",
            "load",
            "stops"
          ],
          "additionalProperties": false
        },
        "description": "One route per vehicle: the vehicle, crew, start and end time, distance (metres), duration, load, and its stops in order (start, job, break, end); a job stop names its request, with its position and arrival and departure times. The positions repeat the requests' locations"
      },
      "unassigned": {
        "type": [
          "array",
          "null"
        ],
        "items": {
          "type": "string",
          "description": "(a URI)"
        },
        "description": "The requests that did not fit (ServiceRequest ids); an empty array when all did (no duplicates)"
      },
      "totalDistance": {
        "type": [
          "number",
          "null"
        ],
        "description": "The distance of all routes together, in metres (minimum 0)"
      },
      "totalDuration": {
        "type": [
          "string",
          "null"
        ],
        "description": "The time of all routes together, as an ISO 8601 duration (must match the pattern ^P(?!$)(\\d+D)?(T(?=\\d)(\\d+H)?(\\d+M)?(\\d+(\\.\\d+)?S)?)?$)"
      },
      "source": {
        "type": [
          "string",
          "null"
        ],
        "description": "Where the data comes from (a URL, for example) (not empty)"
      }
    },
    "required": [
      "provider",
      "localGovernmentCode",
      "area",
      "planDate",
      "planStatus",
      "statusLabel",
      "planner",
      "computedAt",
      "vehicles",
      "serviceRequests",
      "routes",
      "unassigned",
      "totalDistance",
      "totalDuration",
      "source"
    ],
    "additionalProperties": false
  }
}
