{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "title": "VigilCare Clinical Scenario",
  "type": "object",
  "required": ["scenario", "patient", "encounter", "events"],
  "properties": {
    "scenario": {
      "type": "object",
      "required": ["id", "name"],
      "properties": {
        "id": { "type": "string", "pattern": "^[a-z0-9-]+$" },
        "name": { "type": "string" },
        "description": { "type": "string" },
        "durationMinutes": { "type": "integer", "minimum": 1 },
        "tags": { "type": "array", "items": { "type": "string" } }
      }
    },
    "patient": {
      "type": "object",
      "required": ["firstName", "lastName", "dateOfBirth", "gender"],
      "properties": {
        "firstName": { "type": "string" },
        "lastName": { "type": "string" },
        "dateOfBirth": { "type": "string", "format": "date" },
        "gender": { "type": "string", "enum": ["Male", "Female"] }
      }
    },
    "encounter": {
      "type": "object",
      "required": ["department", "encounterType", "attendingPhysician"],
      "properties": {
        "department": { "type": "string", "enum": ["Icu", "GeneralMedicine", "Emergency", "Cardiology", "Surgery", "Pediatrics"] },
        "encounterType": { "type": "string", "enum": ["Inpatient", "Outpatient", "Emergency"] },
        "attendingPhysician": { "type": "string" },
        "roomBed": { "type": "string" },
        "admissionReason": { "type": "string" }
      }
    },
    "events": {
      "type": "array",
      "items": {
        "type": "object",
        "required": ["offsetMinutes", "type", "data"],
        "properties": {
          "offsetMinutes": { "type": "number", "minimum": 0 },
          "type": { "type": "string", "enum": ["observation", "order", "order_result", "medication", "alert_ack"] },
          "data": { "type": "object" },
          "note": { "type": "string" }
        }
      }
    },
    "expectedOutcomes": {
      "type": "array",
      "items": {
        "type": "object",
        "required": ["afterOffsetMinutes", "type"],
        "properties": {
          "afterOffsetMinutes": { "type": "number", "minimum": 0 },
          "type": { "type": "string", "enum": ["alert", "score", "bundle"] },
          "alertType": { "type": "string" },
          "scoreType": { "type": "string" },
          "expectedMinimum": { "type": "number" },
          "description": { "type": "string" }
        }
      }
    },
    "observationCodes": {
      "type": "array",
      "description": "Valid observation codes",
      "items": {
        "enum": [
          "HEART_RATE", "RESP_RATE", "SYSTOLIC_BP", "DIASTOLIC_BP",
          "TEMP_C", "SPO2", "AVPU", "SUPPLEMENTAL_O2",
          "WBC_K_UL", "POTASSIUM_MEQ_L", "LACTATE_MMOL_L", "GLUCOSE_MG_DL",
          "GCS_EYE", "GCS_VERBAL", "GCS_MOTOR",
          "PAO2_MMHG", "FIO2_PCT", "PLATELET_K_UL",
          "BILIRUBIN_MG_DL", "CREATININE_MG_DL", "URINE_OUTPUT_ML_H"
        ]
      }
    }
  }
}