{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/regrow-ag/json-schema/regrow-ag-rancher-input-schema.json",
  "title": "RancherInput",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/regrow-ag-v1-measure-api-enteric-api-openapi.yml#/components/schemas/RancherInput",
  "properties": {
    "name": {
      "type": "string",
      "title": "Rancher Name"
    },
    "practice_change": {
      "anyOf": [
        {
          "$ref": "#/$defs/PracticeChangeEnum"
        },
        {
          "type": "null"
        }
      ]
    },
    "cohorts": {
      "items": {
        "$ref": "#/$defs/Cohort"
      },
      "type": "array",
      "minItems": 1,
      "title": "Cohorts"
    },
    "reporting_information": {
      "allOf": [
        {
          "$ref": "#/$defs/scenarios_service_schema__public__enteric__v1__input__ReportingInformation"
        }
      ],
      "description": "The length of a reporting period must be at least 365 days.\n\n`Cohort`(s) that exist before the project `program_start_date` form the baseline period, and the length of the baseline period must be at least two years. Therefore, at least one `Cohort` with a `start_date` at minimum two years before the `program_start_date` must exist in order to satisfy the baseline period length requirement."
    }
  },
  "additionalProperties": false,
  "type": "object",
  "required": [
    "name",
    "cohorts",
    "reporting_information"
  ],
  "$defs": {
    "ArrivalEvent": {
      "properties": {
        "date": {
          "type": "string",
          "title": "Date",
          "description": "Format is \"YYYY-MM-DD\""
        },
        "type": {
          "type": "string",
          "const": "arrival",
          "title": "Type",
          "default": "arrival"
        },
        "count": {
          "type": "integer",
          "minimum": 1.0,
          "title": "Count"
        },
        "total_start_weight": {
          "allOf": [
            {
              "$ref": "#/$defs/TotalWeight"
            }
          ],
          "description": "Total start weight per animal, must be greater than 0."
        }
      },
      "additionalProperties": false,
      "type": "object",
      "required": [
        "date",
        "count",
        "total_start_weight"
      ],
      "title": "ArrivalEvent"
    },
    "BeefCattleAgeClassEnum": {
      "type": "string",
      "enum": [
        "bull",
        "calf",
        "cow",
        "heifer_calf",
        "steer_calf",
        "weaner",
        "weaned_bull",
        "weaned_heifer",
        "weaned_steer",
        "yearling",
        "yearling_heifer",
        "yearling_steer",
        "feedlot"
      ],
      "title": "BeefCattleAgeClassEnum"
    },
    "Cohort": {
      "properties": {
        "start_date": {
          "type": "string",
          "title": "Start Date",
          "description": "Format is \"YYYY-MM-DD\""
        },
        "end_date": {
          "type": "string",
          "title": "End Date",
          "description": "Format is \"YYYY-MM-DD\""
        },
        "name": {
          "type": "string",
          "title": "Cohort Name",
          "description": "Cohort names must be unique."
        },
        "location": {
          "$ref": "#/$defs/Location"
        },
        "livestock": {
          "$ref": "#/$defs/Livestock"
        },
        "initial_head_count": {
          "type": "integer",
          "minimum": 0.0,
          "title": "Initial Head Count"
        },
        "total_end_weight": {
          "allOf": [
            {
              "$ref": "#/$defs/TotalWeight"
            }
          ],
          "description": "Total end weight per animal."
        },
        "total_start_weight": {
          "allOf": [
            {
              "$ref": "#/$defs/TotalWeight"
            }
          ],
          "description": "Total start weight per animal."
        },
        "diet": {
          "items": {
            "$ref": "#/$defs/Diet"
          },
          "type": "array",
          "minItems": 1,
          "title": "The diet(s) of the Cohort",
          "description": "Diets can be overlapping but must be within the time period of the `Cohort`. There must be at least one `Diet` active on the days when the `Cohort` has a positive head count."
        },
        "management_events": {
          "items": {
            "anyOf": [
              {
                "$ref": "#/$defs/ArrivalEvent"
              },
              {
                "$ref": "#/$defs/DepartureEvent"
              }
            ]
          },
          "type": "array",
          "title": "Management Events",
          "default": []
        }
      },
      "additionalProperties": false,
      "type": "object",
      "required": [
        "start_date",
        "end_date",
        "name",
        "location",
        "livestock",
        "initial_head_count",
        "total_end_weight",
        "total_start_weight",
        "diet"
      ],
      "title": "Cohort"
    },
    "DepartureEvent": {
      "properties": {
        "date": {
          "type": "string",
          "title": "Date",
          "description": "Format is \"YYYY-MM-DD\""
        },
        "type": {
          "type": "string",
          "const": "departure",
          "title": "Type",
          "default": "departure"
        },
        "count": {
          "type": "integer",
          "minimum": 1.0,
          "title": "Count",
          "description": "If a departure event reduces the Cohort's head count to 0, then the Cohort must end on the same date as the departure event."
        },
        "departure_type": {
          "$ref": "#/$defs/DepartureTypeEnum",
          "default": "non_terminal"
        },
        "departure_end_weight": {
          "allOf": [
            {
              "$ref": "#/$defs/TotalWeight"
            }
          ],
          "description": "Total end weight per animal, must be greater than 0."
        }
      },
      "additionalProperties": false,
      "type": "object",
      "required": [
        "date",
        "count",
        "departure_end_weight"
      ],
      "title": "DepartureEvent"
    },
    "DepartureTypeEnum": {
      "type": "string",
      "enum": [
        "non_terminal",
        "terminal"
      ],
      "title": "DepartureTypeEnum"
    },
    "Diet": {
      "properties": {
        "start_date": {
          "type": "string",
          "title": "Start Date",
          "description": "Format is \"YYYY-MM-DD\""
        },
        "end_date": {
          "type": "string",
          "title": "End Date",
          "description": "Format is \"YYYY-MM-DD\""
        },
        "dry_matter_intake": {
          "anyOf": [
            {
              "$ref": "#/$defs/DryMatterIntake"
            },
            {
              "type": "null"
            }
          ]
        },
        "neutral_detergent_fiber_percentage": {
          "anyOf": [
            {
              "type": "number",
              "maximum": 100.0,
              "minimum": 0.0
            },
            {
              "type": "null"
            }
          ],
          "title": "Neutral Detergent Fiber (%)"
        },
        "gross_energy_intake": {
          "anyOf": [
            {
              "type": "number",
              "exclusiveMinimum": 0.0
            },
            {
              "type": "null"
            }
          ],
          "title": "Gross Energy in Feed (MJ/day)",
          "description": "Gross Energy Intake is the total amount of energy the animal eats each day from its feed. If the value is not provided, a default value will be provided."
        },
        "crude_protein_percentage": {
          "type": "number",
          "maximum": 100.0,
          "minimum": 0.0,
          "title": "Crude Protein (%)",
          "description": "Optional and defaulted if not informed.",
          "default": 0.0
        },
        "acid_detergent_fiber_percentage": {
          "type": "number",
          "maximum": 100.0,
          "minimum": 0.0,
          "title": "Acid Detergent Fiber (%)",
          "description": "Optional and defaulted if not informed.",
          "default": 0.0
        },
        "type": {
          "allOf": [
            {
              "$ref": "#/$defs/DietTypeEnum"
            }
          ],
          "description": "\"grazing\":\n* `dry_matter_intake`: Not required. If provided, then must be > 0. If not provided, then DMI is calculated by Regrow.\n* `neutral_detergent_fiber_percentage`: Not required. If provided, then must be > 0. If not provided, then a value is calculated by Regrow.\n\n\"supplemental\":\n* `dry_matter_intake`: Required, can be = or > 0\n* `neutral_detergent_fiber_percentage`: Required, can be = or > 0.\n\n\"nursing\":\n* This diet type is restricted to the following calf age classes: `calf`, `heifer_calf`, `steer_calf`.\n* `dry_matter_intake`: Not required. If provided, then must be 0.\n* `neutral_detergent_fiber_percentage`: Required, can be = or > 0.\n\n"
        }
      },
      "additionalProperties": false,
      "type": "object",
      "required": [
        "start_date",
        "end_date",
        "type"
      ],
      "title": "Diet",
      "description": "The diet of a `Cohort` for a given period of time."
    },
    "DietTypeEnum": {
      "type": "string",
      "enum": [
        "grazing",
        "supplemental",
        "nursing"
      ],
      "title": "DietTypeEnum"
    },
    "DryMatterIntake": {
      "properties": {
        "value": {
          "type": "number",
          "minimum": 0.0,
          "title": "Value"
        },
        "unit": {
          "$ref": "#/$defs/scenarios_service_schema__public__enteric__common__MassUnitEnum"
        },
        "time_period": {
          "$ref": "#/$defs/TimePeriodEnum"
        }
      },
      "additionalProperties": false,
      "type": "object",
      "required": [
        "value",
        "unit",
        "time_period"
      ],
      "title": "DryMatterIntake",
      "description": "Dry Matter Intake"
    },
    "Livestock": {
      "properties": {
        "type": {
          "$ref": "#/$defs/LivestockTypeEnum"
        },
        "age_class": {
          "$ref": "#/$defs/BeefCattleAgeClassEnum"
        }
      },
      "additionalProperties": false,
      "type": "object",
      "required": [
        "type",
        "age_class"
      ],
      "title": "Livestock"
    },
    "LivestockTypeEnum": {
      "type": "string",
      "enum": [
        "beef_cattle"
      ],
      "title": "LivestockTypeEnum"
    },
    "Location": {
      "properties": {
        "boundary": {
          "anyOf": [
            {
              "$ref": "#/$defs/Polygon"
            },
            {
              "$ref": "#/$defs/MultiPolygon"
            }
          ],
          "title": "Boundary",
          "description": "GeoJSON describing the field boundaries. The geometry type must be 'Polygon' or `MultiPolygon`."
        }
      },
      "additionalProperties": false,
      "type": "object",
      "required": [
        "boundary"
      ],
      "title": "Location",
      "description": "The `Location` object contains geospatial data representing a field's location."
    },
    "MultiPolygon": {
      "properties": {
        "type": {
          "type": "string",
          "const": "MultiPolygon",
          "title": "Type",
          "default": "MultiPolygon"
        },
        "coordinates": {
          "items": {
            "items": {
              "items": {
                "items": {
                  "type": "number"
                },
                "type": "array"
              },
              "type": "array"
            },
            "type": "array"
          },
          "type": "array",
          "title": "Coordinates"
        }
      },
      "additionalProperties": false,
      "type": "object",
      "required": [
        "coordinates"
      ],
      "title": "MultiPolygon"
    },
    "Polygon": {
      "properties": {
        "type": {
          "type": "string",
          "const": "Polygon",
          "title": "Type",
          "default": "Polygon"
        },
        "coordinates": {
          "items": {
            "items": {
              "items": {
                "type": "number"
              },
              "type": "array"
            },
            "type": "array"
          },
          "type": "array",
          "title": "Coordinates"
        }
      },
      "additionalProperties": false,
      "type": "object",
      "required": [
        "coordinates"
      ],
      "title": "Polygon"
    },
    "PracticeChangeEnum": {
      "type": "string",
      "enum": [
        "fencing",
        "improved_forage",
        "improved_genetics",
        "improved_grazing",
        "soil_biology",
        "water_infrastructure"
      ],
      "title": "PracticeChangeEnum",
      "description": "The type of practice change."
    },
    "TimePeriodEnum": {
      "type": "string",
      "enum": [
        "day"
      ],
      "title": "TimePeriodEnum"
    },
    "TotalWeight": {
      "properties": {
        "value": {
          "type": "number",
          "minimum": 0.0,
          "title": "Value"
        },
        "unit": {
          "$ref": "#/$defs/scenarios_service_schema__public__enteric__common__MassUnitEnum"
        }
      },
      "additionalProperties": false,
      "type": "object",
      "required": [
        "value",
        "unit"
      ],
      "title": "TotalWeight",
      "description": "Total weight per animal"
    },
    "scenarios_service_schema__public__enteric__common__MassUnitEnum": {
      "type": "string",
      "enum": [
        "pound"
      ],
      "title": "MassUnitEnum"
    },
    "scenarios_service_schema__public__enteric__v1__input__ReportingInformation": {
      "properties": {
        "start_date": {
          "type": "string",
          "title": "Start Date",
          "description": "Format is \"YYYY-MM-DD\". Represents the date the reporting period begins."
        },
        "end_date": {
          "type": "string",
          "title": "End Date",
          "description": "Format is \"YYYY-MM-DD\". Represents the date the reporting period ends."
        }
      },
      "additionalProperties": false,
      "type": "object",
      "required": [
        "start_date",
        "end_date"
      ],
      "title": "ReportingInformation"
    }
  }
}