{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://voocie.com/record-format.json",
  "title": "voocie-record-v1",
  "description": "Open pet health record. The animal's story in one portable JSON object. Extensions: namespace new fields x_yourapp_*; never repurpose existing ones.",
  "type": "object",
  "required": [
    "format",
    "pet",
    "timeline_events"
  ],
  "properties": {
    "format": {
      "const": "voocie-record-v1"
    },
    "exported_at": {
      "type": "string",
      "format": "date-time"
    },
    "pet": {
      "type": "object",
      "required": [
        "name"
      ],
      "properties": {
        "name": {
          "type": "string"
        },
        "species": {
          "type": [
            "string",
            "null"
          ]
        },
        "breed": {
          "type": [
            "string",
            "null"
          ]
        },
        "sex": {
          "type": [
            "string",
            "null"
          ]
        },
        "dob": {
          "type": [
            "string",
            "null"
          ],
          "format": "date"
        },
        "weight_kg": {
          "type": [
            "number",
            "null"
          ]
        },
        "microchip": {
          "type": [
            "string",
            "null"
          ],
          "description": "Identity is corroborated, never trusted alone: microchip + clinic record numbers + photo + DNA test IDs."
        },
        "status": {
          "type": [
            "string",
            "null"
          ],
          "enum": [
            "memorial",
            null
          ]
        },
        "daily_food_target": {
          "type": [
            "string",
            "null"
          ]
        },
        "insurance": {
          "type": "object",
          "properties": {
            "provider": {
              "type": [
                "string",
                "null"
              ]
            },
            "policy": {
              "type": [
                "string",
                "null"
              ]
            }
          }
        },
        "dna": {
          "type": "object",
          "properties": {
            "provider": {
              "type": [
                "string",
                "null"
              ]
            },
            "test_id": {
              "type": [
                "string",
                "null"
              ]
            },
            "url": {
              "type": [
                "string",
                "null"
              ]
            }
          }
        }
      }
    },
    "timeline_events": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "type",
          "payload"
        ],
        "properties": {
          "type": {
            "type": "string",
            "enum": [
              "visit",
              "lab",
              "diagnosis",
              "medication",
              "dose",
              "vaccine",
              "allergy",
              "surgery",
              "weight",
              "intake",
              "exercise",
              "note",
              "er_intake"
            ]
          },
          "event_date": {
            "type": [
              "string",
              "null"
            ],
            "format": "date"
          },
          "event_time": {
            "type": [
              "string",
              "null"
            ],
            "pattern": "^[0-2][0-9]:[0-5][0-9]$"
          },
          "payload": {
            "type": "object",
            "description": "Typed per event type; every structured fact traces to a document or an owner entry."
          }
        }
      }
    },
    "documents": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "original_name": {
            "type": [
              "string",
              "null"
            ]
          },
          "mime_type": {
            "type": [
              "string",
              "null"
            ]
          },
          "extraction": {
            "type": [
              "object",
              "null"
            ]
          },
          "download_path": {
            "type": "string"
          }
        }
      }
    },
    "foods": {
      "type": "array"
    },
    "memories": {
      "type": "array"
    },
    "providers": {
      "type": "array"
    },
    "family_tree": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          },
          "rel_type": {
            "type": "string",
            "enum": [
              "mother",
              "father",
              "littermate",
              "offspring",
              "family"
            ]
          },
          "rel_note": {
            "type": [
              "string",
              "null"
            ]
          },
          "blood": {
            "type": "integer",
            "enum": [
              0,
              1
            ],
            "description": "0 = family by heart (step/adopted): hereditary lines about this relative imply NO genetic risk."
          }
        }
      }
    },
    "family_health_history": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "relation": {
            "type": [
              "string",
              "null"
            ]
          },
          "text": {
            "type": "string"
          },
          "about": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      }
    }
  }
}