{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://veydrin.codeberg.page/protocols/ohds/ohds-v1.1.schema.json",
  "title": "OHDS v1.1 \u2014 Open Hive Data Standard",
  "description": "Schema for beekeeping citizen science data exports. Builds on the VODS v1.0 envelope.",
  "allOf": [
    {
      "$ref": "https://veydrin.codeberg.page/protocols/vods/vods-v1.0.schema.json"
    },
    {
      "type": "object",
      "required": [
        "ohds_version"
      ],
      "anyOf": [
        {
          "required": [
            "inspections"
          ]
        },
        {
          "required": [
            "apiary_summary"
          ]
        },
        {
          "required": [
            "harvests"
          ]
        },
        {
          "required": [
            "pollinator_observations"
          ]
        },
        {
          "required": [
            "forage_observations"
          ]
        }
      ],
      "properties": {
        "ohds_version": {
          "type": "string",
          "pattern": "^1\\.[0-9]+$"
        },
        "extensions": {
          "type": "object",
          "additionalProperties": {
            "type": "object"
          }
        },
        "inspections": {
          "type": "array",
          "minItems": 1,
          "items": {
            "type": "object",
            "required": [
              "inspection_date",
              "apiary_ref",
              "hive_ref",
              "colony_status"
            ],
            "properties": {
              "inspection_date": {
                "type": "string",
                "format": "date"
              },
              "apiary_ref": {
                "type": "string"
              },
              "hive_ref": {
                "type": "string"
              },
              "colony_status": {
                "type": "string",
                "enum": [
                  "alive",
                  "dead",
                  "absconded",
                  "lost_queen",
                  "split",
                  "merged"
                ]
              },
              "hive_type": {
                "type": "string",
                "enum": [
                  "langstroth",
                  "top_bar",
                  "warre",
                  "flow",
                  "long",
                  "skep",
                  "other"
                ]
              },
              "bee_race": {
                "type": "string",
                "enum": [
                  "italian",
                  "carniolan",
                  "russian",
                  "buckfast",
                  "caucasian",
                  "local_mutt",
                  "africanized",
                  "unknown",
                  "other"
                ]
              },
              "brood_pattern": {
                "type": "string",
                "enum": [
                  "solid",
                  "spotty",
                  "none"
                ]
              },
              "queen_seen": {
                "type": "boolean"
              },
              "queen_status": {
                "type": "string",
                "enum": [
                  "present",
                  "missing",
                  "replaced",
                  "supersedure",
                  "unknown"
                ]
              },
              "frames_of_bees": {
                "type": "number",
                "minimum": 0
              },
              "frames_of_brood": {
                "type": "number",
                "minimum": 0
              },
              "frames_of_honey": {
                "type": "number",
                "minimum": 0
              },
              "varroa_count": {
                "type": "number",
                "minimum": 0
              },
              "varroa_method": {
                "type": "string",
                "enum": [
                  "alcohol_wash",
                  "sugar_roll",
                  "sticky_board",
                  "drone_uncapping"
                ]
              },
              "treatments": {
                "type": "array",
                "items": {
                  "type": "object",
                  "required": [
                    "product",
                    "method"
                  ],
                  "properties": {
                    "product": {
                      "type": "string"
                    },
                    "method": {
                      "type": "string",
                      "enum": [
                        "vaporization",
                        "strip",
                        "drizzle",
                        "drench",
                        "dusting",
                        "fogger",
                        "feed_additive",
                        "other"
                      ]
                    },
                    "date_start": {
                      "type": "string",
                      "format": "date"
                    },
                    "date_end": {
                      "type": "string",
                      "format": "date"
                    }
                  },
                  "additionalProperties": false
                }
              },
              "feeding": {
                "type": "object",
                "required": [
                  "type",
                  "quantity_kg"
                ],
                "properties": {
                  "type": {
                    "type": "string",
                    "enum": [
                      "sugar_syrup_1:1",
                      "sugar_syrup_2:1",
                      "dry_sugar",
                      "candy",
                      "pollen_sub",
                      "other"
                    ]
                  },
                  "quantity_kg": {
                    "type": "number",
                    "minimum": 0
                  }
                },
                "additionalProperties": false
              },
              "weight_kg": {
                "type": "number",
                "minimum": 0
              },
              "temperature_c": {
                "type": "number"
              },
              "weather": {
                "type": "string",
                "enum": [
                  "sunny",
                  "partly_cloudy",
                  "overcast",
                  "rain",
                  "wind"
                ]
              },
              "notes": {
                "type": "string"
              },
              "coordinates": {
                "type": "object",
                "required": [
                  "lat",
                  "lon"
                ],
                "properties": {
                  "lat": {
                    "type": "number",
                    "minimum": -90,
                    "maximum": 90
                  },
                  "lon": {
                    "type": "number",
                    "minimum": -180,
                    "maximum": 180
                  }
                },
                "additionalProperties": false
              }
            },
            "additionalProperties": false
          }
        },
        "apiary_summary": {
          "type": "array",
          "minItems": 1,
          "items": {
            "type": "object",
            "required": [
              "apiary_ref",
              "season",
              "year",
              "colonies_start",
              "colonies_end"
            ],
            "properties": {
              "apiary_ref": {
                "type": "string"
              },
              "season": {
                "type": "string",
                "enum": [
                  "winter",
                  "spring",
                  "summer",
                  "fall",
                  "annual"
                ]
              },
              "year": {
                "type": "string",
                "pattern": "^[0-9]{4}(-[0-9]{4})?$"
              },
              "season_start": {
                "type": "string",
                "format": "date"
              },
              "season_end": {
                "type": "string",
                "format": "date"
              },
              "colonies_start": {
                "type": "integer",
                "minimum": 0
              },
              "colonies_end": {
                "type": "integer",
                "minimum": 0
              },
              "lost_dead": {
                "type": "integer",
                "minimum": 0
              },
              "lost_queen": {
                "type": "integer",
                "minimum": 0
              },
              "lost_disaster": {
                "type": "integer",
                "minimum": 0
              },
              "new_purchased": {
                "type": "integer",
                "minimum": 0
              },
              "new_splits": {
                "type": "integer",
                "minimum": 0
              },
              "colonies_sold": {
                "type": "integer",
                "minimum": 0
              },
              "perceived_loss_causes": {
                "type": "array",
                "items": {
                  "type": "string",
                  "enum": [
                    "varroa",
                    "nosema",
                    "pesticides",
                    "starvation",
                    "weather",
                    "ccd",
                    "weak_fall",
                    "queen_failure",
                    "other",
                    "unknown"
                  ]
                }
              },
              "operation_size": {
                "type": "string",
                "enum": [
                  "backyard",
                  "sideline",
                  "commercial"
                ]
              },
              "migratory": {
                "type": "boolean"
              },
              "region": {
                "type": "string"
              }
            },
            "additionalProperties": false
          }
        },
        "harvests": {
          "type": "array",
          "minItems": 1,
          "items": {
            "type": "object",
            "required": [
              "harvest_date",
              "apiary_ref",
              "product",
              "quantity",
              "unit"
            ],
            "properties": {
              "harvest_date": {
                "type": "string",
                "format": "date"
              },
              "apiary_ref": {
                "type": "string"
              },
              "hive_ref": {
                "type": "string"
              },
              "product": {
                "type": "string",
                "enum": [
                  "honey",
                  "wax",
                  "propolis",
                  "pollen",
                  "royal_jelly",
                  "other"
                ]
              },
              "quantity": {
                "type": "number"
              },
              "unit": {
                "type": "string",
                "enum": [
                  "kg",
                  "lb",
                  "g",
                  "oz",
                  "litre",
                  "gallon",
                  "frame"
                ]
              },
              "honey_type": {
                "type": "string"
              },
              "moisture_pct": {
                "type": "number"
              },
              "notes": {
                "type": "string"
              }
            }
          }
        },
        "pollinator_observations": {
          "type": "array",
          "minItems": 1,
          "items": {
            "type": "object",
            "required": [
              "observation_date",
              "species"
            ],
            "properties": {
              "observation_date": {
                "type": "string",
                "format": "date"
              },
              "species": {
                "type": "string"
              },
              "species_group": {
                "type": "string",
                "enum": [
                  "honey_bee",
                  "bumble_bee",
                  "solitary_bee",
                  "wasp",
                  "butterfly",
                  "moth",
                  "hoverfly",
                  "beetle",
                  "bird",
                  "bat",
                  "other"
                ]
              },
              "count": {
                "type": "integer"
              },
              "behavior": {
                "type": "string",
                "enum": [
                  "foraging",
                  "nesting",
                  "resting",
                  "mating",
                  "transiting",
                  "other"
                ]
              },
              "plant_observed_on": {
                "type": "string"
              },
              "photo_ref": {
                "type": "string"
              },
              "coordinates": {
                "type": "object",
                "properties": {
                  "lat": {
                    "type": "number"
                  },
                  "lon": {
                    "type": "number"
                  }
                }
              },
              "region": {
                "type": "string"
              },
              "notes": {
                "type": "string"
              }
            }
          }
        },
        "forage_observations": {
          "type": "array",
          "minItems": 1,
          "items": {
            "type": "object",
            "required": [
              "observation_date",
              "plant_name"
            ],
            "properties": {
              "observation_date": {
                "type": "string",
                "format": "date"
              },
              "plant_name": {
                "type": "string"
              },
              "bloom_stage": {
                "type": "string",
                "enum": [
                  "budding",
                  "early_bloom",
                  "peak_bloom",
                  "late_bloom",
                  "done"
                ]
              },
              "nectar_flow": {
                "type": "string",
                "enum": [
                  "none",
                  "light",
                  "moderate",
                  "heavy"
                ]
              },
              "pollen_available": {
                "type": "boolean"
              },
              "abundance": {
                "type": "string",
                "enum": [
                  "rare",
                  "scattered",
                  "common",
                  "dominant"
                ]
              },
              "photo_ref": {
                "type": "string"
              },
              "coordinates": {
                "type": "object",
                "properties": {
                  "lat": {
                    "type": "number"
                  },
                  "lon": {
                    "type": "number"
                  }
                }
              },
              "region": {
                "type": "string"
              },
              "notes": {
                "type": "string"
              }
            }
          }
        }
      },
      "additionalProperties": true
    }
  ]
}