{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://trp.ecoclaim.ca/schemas/v3/mitigation-event.schema.json",
  "title": "TRP MitigationEvent",
  "description": "One observed unit of mitigation work. Draft 3.0.0-draft; expected to change.",
  "allOf": [{ "$ref": "common.schema.json#/$defs/envelope" }],
  "type": "object",
  "required": ["claim_id", "job_id", "event_time", "reported_by", "activity", "area", "verification_status"],
  "properties": {
    "type": { "const": "trp.mitigation_event" },
    "claim_id": { "$ref": "common.schema.json#/$defs/identifier" },
    "job_id": { "$ref": "common.schema.json#/$defs/identifier" },
    "event_time": { "$ref": "common.schema.json#/$defs/timestamp" },
    "reported_by": { "$ref": "common.schema.json#/$defs/identifier" },
    "activity": {
      "enum": ["inspection", "water_extraction", "equipment_placement", "equipment_removal", "moisture_reading", "cleaning", "antimicrobial_application", "containment", "demolition_for_drying", "other"]
    },
    "area": {
      "type": "object",
      "required": ["room"],
      "properties": {
        "structure": { "type": "string" },
        "level": { "type": "string" },
        "room": { "type": "string", "minLength": 1 },
        "description": { "type": "string" }
      }
    },
    "loss_context": {
      "type": "object",
      "properties": {
        "peril": { "type": "string" },
        "classification_system": { "type": "string" },
        "water_category": { "type": "string" },
        "damage_class": { "type": "string" }
      }
    },
    "equipment": {
      "type": "array",
      "items": {
        "type": "object",
        "required": ["equipment_type", "count"],
        "properties": {
          "equipment_type": { "type": "string", "minLength": 1 },
          "count": { "type": "integer", "minimum": 1 },
          "identifier": { "type": "string" },
          "running_hours": { "type": "number", "minimum": 0 }
        }
      }
    },
    "readings": {
      "type": "array",
      "items": {
        "type": "object",
        "required": ["material", "value", "unit", "method"],
        "properties": {
          "material": { "type": "string", "minLength": 1 },
          "method": { "type": "string", "minLength": 1 },
          "value": { "type": "number" },
          "unit": { "type": "string", "minLength": 1 },
          "dry_standard": { "$ref": "common.schema.json#/$defs/quantity" }
        }
      }
    },
    "judgment": {
      "type": "object",
      "required": ["statement", "made_by", "standard"],
      "properties": {
        "statement": { "enum": ["drying_goal_met", "drying_goal_not_met", "not_assessed"] },
        "made_by": { "$ref": "common.schema.json#/$defs/identifier" },
        "standard": { "type": "string", "minLength": 1 }
      }
    },
    "verification_status": { "$ref": "common.schema.json#/$defs/verificationStatus" }
  }
}
