{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://vetdatastandards.com/schemas/v0.1/location.schema.json",
  "title": "Location",
  "type": "object",
  "additionalProperties": false,
  "required": ["id", "practiceId", "name", "source"],
  "properties": {
    "id": { "$ref": "https://vetdatastandards.com/schemas/v0.1/common.schema.json#/$defs/id" },
    "source": { "$ref": "https://vetdatastandards.com/schemas/v0.1/common.schema.json#/$defs/source" },
    "matchKeys": { "$ref": "https://vetdatastandards.com/schemas/v0.1/common.schema.json#/$defs/matchKeys" },
    "createdAt": { "$ref": "https://vetdatastandards.com/schemas/v0.1/common.schema.json#/$defs/dateTime" },
    "updatedAt": { "$ref": "https://vetdatastandards.com/schemas/v0.1/common.schema.json#/$defs/dateTime" },
    "deletedAt": { "$ref": "https://vetdatastandards.com/schemas/v0.1/common.schema.json#/$defs/dateTime" },
    "active": { "type": "boolean" },
    "extensions": { "$ref": "https://vetdatastandards.com/schemas/v0.1/common.schema.json#/$defs/extensions" },
    "practiceId": { "$ref": "https://vetdatastandards.com/schemas/v0.1/common.schema.json#/$defs/id" },
    "parentLocationId": { "$ref": "https://vetdatastandards.com/schemas/v0.1/common.schema.json#/$defs/id" },
    "name": { "type": "string", "minLength": 1, "maxLength": 255 },
    "address": { "$ref": "https://vetdatastandards.com/schemas/v0.1/common.schema.json#/$defs/address" },
    "phone": { "type": "string", "minLength": 1, "maxLength": 64 },
    "kind": {
      "type": "string",
      "enum": ["clinic", "client_premises", "other"]
    },
    "kindRaw": { "$ref": "https://vetdatastandards.com/schemas/v0.1/common.schema.json#/$defs/rawText" },
    "isPrimary": { "type": "boolean" },
    "notes": { "type": "string", "maxLength": 4096 }
  },
  "if": {
    "properties": { "kind": { "const": "other" } },
    "required": ["kind"]
  },
  "then": {
    "required": ["kindRaw"]
  }
}
