{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://vitatally-evidence.pages.dev/evidence/v1/weekly-activity-risk-curves.schema.json",
  "title": "Vitatally EWMA habitual-dose live-session pooled-RR contract",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schemaVersion",
    "dataVersion",
    "generatedAt",
    "title",
    "calculation",
    "intensityDoseMapping",
    "rendering",
    "models",
    "workedExamples",
    "globalLimitations"
  ],
  "properties": {
    "schemaVersion": { "const": "2.2.0" },
    "dataVersion": { "type": "string", "minLength": 1 },
    "generatedAt": { "type": "string", "format": "date-time" },
    "title": { "$ref": "#/$defs/localized" },
    "calculation": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "activityWindow",
        "feedbackUpdateTrigger",
        "doseUnit",
        "doseFormula",
        "currentPercentBelowInactiveReference",
        "currentSessionPercentBelowInactiveReferenceIncreasePercentagePoints",
        "nextMinutePercentBelowInactiveReferenceIncreasePercentagePoints",
        "displayUpdatesImmediatelyFromSessionProgress",
        "immediateDisplayIsAcuteBiologicalEffect",
        "confidenceIntervalForIncrementAvailable",
        "absoluteRiskCalculationAvailable",
        "causalEffectClaimed",
        "habitualDoseEWMA"
      ],
      "properties": {
        "activityWindow": { "const": "ewmaHabitualDoseIncludingCurrentSession" },
        "feedbackUpdateTrigger": { "const": "onEveryCompletedSessionMinute" },
        "doseUnit": { "const": "marginalMETHourPerWeek" },
        "doseFormula": { "type": "string", "minLength": 1 },
        "currentPercentBelowInactiveReference": { "type": "string", "minLength": 1 },
        "currentSessionPercentBelowInactiveReferenceIncreasePercentagePoints": {
          "type": "string",
          "minLength": 1
        },
        "nextMinutePercentBelowInactiveReferenceIncreasePercentagePoints": {
          "type": "string",
          "minLength": 1
        },
        "displayUpdatesImmediatelyFromSessionProgress": { "const": true },
        "immediateDisplayIsAcuteBiologicalEffect": { "const": false },
        "confidenceIntervalForIncrementAvailable": { "const": false },
        "absoluteRiskCalculationAvailable": { "const": false },
        "causalEffectClaimed": { "const": false },
        "habitualDoseEWMA": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "halfLifeDaysSymbol",
            "halfLifeIsProductParameterNotBiologicalEffectHalfLife",
            "dailyRetentionFormula",
            "newDailyRecordWeightFormula",
            "dailyEquivalentWeeklyDoseFormula",
            "habitualDoseUpdateFormula",
            "liveSessionDoseFormula",
            "nextLiveMinuteDoseIncrementFormula",
            "noExerciseDayDecayFormula",
            "longTermRelativeRiskReductionEstimatePercent",
            "signedDailyChangePercentagePoints",
            "positiveChangeMeaning",
            "negativeChangeMeaning",
            "averageDoseBeforeApplyingDiseaseCurve",
            "acuteBiologicalEffectClaimed",
            "causalEffectClaimed"
          ],
          "properties": {
            "halfLifeDaysSymbol": { "const": "h" },
            "halfLifeIsProductParameterNotBiologicalEffectHalfLife": { "const": true },
            "dailyRetentionFormula": { "type": "string", "minLength": 1 },
            "newDailyRecordWeightFormula": { "type": "string", "minLength": 1 },
            "dailyEquivalentWeeklyDoseFormula": { "type": "string", "minLength": 1 },
            "habitualDoseUpdateFormula": { "type": "string", "minLength": 1 },
            "liveSessionDoseFormula": { "type": "string", "minLength": 1 },
            "nextLiveMinuteDoseIncrementFormula": { "type": "string", "minLength": 1 },
            "noExerciseDayDecayFormula": { "type": "string", "minLength": 1 },
            "longTermRelativeRiskReductionEstimatePercent": { "type": "string", "minLength": 1 },
            "signedDailyChangePercentagePoints": { "type": "string", "minLength": 1 },
            "positiveChangeMeaning": { "const": "rollingHabitEstimateImproved" },
            "negativeChangeMeaning": { "const": "rollingHabitEstimateDeclined" },
            "averageDoseBeforeApplyingDiseaseCurve": { "const": true },
            "acuteBiologicalEffectClaimed": { "const": false },
            "causalEffectClaimed": { "const": false }
          }
        }
      }
    },
    "intensityDoseMapping": {
      "type": "object",
      "additionalProperties": false,
      "required": ["moderate", "vigorous"],
      "properties": {
        "moderate": { "$ref": "#/$defs/intensityMapping" },
        "vigorous": { "$ref": "#/$defs/intensityMapping" }
      }
    },
    "rendering": {
      "type": "object",
      "additionalProperties": false,
      "required": ["cumulativeCurve", "liveSession", "habitualDoseEWMA"],
      "properties": {
        "cumulativeCurve": {
          "type": "object",
          "additionalProperties": false,
          "required": ["xField", "yField", "confidenceIntervalFields"],
          "properties": {
            "xField": { "type": "string" },
            "yField": { "type": "string" },
            "confidenceIntervalFields": {
              "type": "array",
              "prefixItems": [{ "type": "string" }, { "type": "string" }],
              "minItems": 2,
              "maxItems": 2
            }
          }
        },
        "liveSession": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "currentValueField",
            "sessionAddedField",
            "nextMinuteField",
            "primaryLabel",
            "nextMinuteLabel"
          ],
          "properties": {
            "currentValueField": { "type": "string" },
            "sessionAddedField": { "type": "string" },
            "nextMinuteField": { "type": "string" },
            "primaryLabel": { "$ref": "#/$defs/localized" },
            "nextMinuteLabel": { "$ref": "#/$defs/localized" }
          }
        },
        "habitualDoseEWMA": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "sourceCurvePath",
            "currentDoseFormulaPath",
            "estimateFormulaPath",
            "signedChangeFormulaPath",
            "confidenceBandTransform",
            "requiredHalfLifeDisclosure"
          ],
          "properties": {
            "sourceCurvePath": { "type": "string", "minLength": 1 },
            "currentDoseFormulaPath": { "type": "string", "minLength": 1 },
            "estimateFormulaPath": { "type": "string", "minLength": 1 },
            "signedChangeFormulaPath": { "type": "string", "minLength": 1 },
            "confidenceBandTransform": {
              "type": "array",
              "prefixItems": [{ "type": "string" }, { "type": "string" }],
              "minItems": 2,
              "maxItems": 2
            },
            "requiredHalfLifeDisclosure": { "$ref": "#/$defs/localized" }
          }
        }
      }
    },
    "models": {
      "type": "array",
      "minItems": 1,
      "items": { "$ref": "#/$defs/model" }
    },
    "workedExamples": {
      "type": "array",
      "minItems": 1,
      "items": { "$ref": "#/$defs/workedExample" }
    },
    "globalLimitations": {
      "type": "array",
      "minItems": 1,
      "items": { "$ref": "#/$defs/localized" }
    }
  },
  "$defs": {
    "localized": {
      "type": "object",
      "additionalProperties": false,
      "required": ["ko", "en"],
      "properties": {
        "ko": { "type": "string", "minLength": 1 },
        "en": { "type": "string", "minLength": 1 }
      }
    },
    "intensityMapping": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "id",
        "abbreviation",
        "label",
        "representativeGrossMET",
        "marginalMET",
        "marginalMETHourPerMinute"
      ],
      "properties": {
        "id": { "enum": ["moderate", "vigorous"] },
        "abbreviation": { "enum": ["MPA", "VPA"] },
        "label": { "$ref": "#/$defs/localized" },
        "representativeGrossMET": { "type": "number", "exclusiveMinimum": 0 },
        "marginalMET": { "type": "number", "exclusiveMinimum": 0 },
        "marginalMETHourPerMinute": { "type": "number", "exclusiveMinimum": 0 }
      }
    },
    "source": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "id",
        "citation",
        "journal",
        "publicationYear",
        "doi",
        "url",
        "journalQuartile",
        "quartileSystem",
        "quartileSourceUrl",
        "exposureDomain"
      ],
      "properties": {
        "id": { "type": "string", "minLength": 1 },
        "citation": { "type": "string", "minLength": 1 },
        "journal": { "type": "string", "minLength": 1 },
        "publicationYear": { "type": "integer", "minimum": 1900 },
        "doi": { "type": "string", "minLength": 1 },
        "url": { "type": "string", "format": "uri" },
        "journalQuartile": { "const": "Q1" },
        "quartileSystem": { "type": "string", "minLength": 1 },
        "quartileSourceUrl": { "type": "string", "format": "uri" },
        "exposureDomain": {
          "enum": ["nonOccupationalPhysicalActivity", "leisureTimePhysicalActivity"]
        }
      }
    },
    "observationContext": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "minimumIncludedFollowUpYears",
        "medianFollowUpYearsByOutcome",
        "followUpRangeYears",
        "activityAssessmentTiming",
        "adherenceContinuouslyVerified"
      ],
      "properties": {
        "minimumIncludedFollowUpYears": { "type": "number", "minimum": 0 },
        "medianFollowUpYearsByOutcome": { "type": ["number", "null"], "minimum": 0 },
        "followUpRangeYears": {
          "oneOf": [
            { "type": "null" },
            {
              "type": "object",
              "additionalProperties": false,
              "required": ["minimum", "maximum"],
              "properties": {
                "minimum": { "type": "number", "minimum": 0 },
                "maximum": { "type": "number", "minimum": 0 }
              }
            }
          ]
        },
        "activityAssessmentTiming": { "const": "baseline" },
        "adherenceContinuouslyVerified": { "const": false }
      }
    },
    "curveData": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "provider",
        "repositoryUrl",
        "repositoryCommit",
        "rawFileUrl",
        "localFile",
        "sha256",
        "interpolation"
      ],
      "properties": {
        "provider": { "type": "string", "minLength": 1 },
        "repositoryUrl": { "type": "string", "format": "uri" },
        "repositoryCommit": { "type": "string", "pattern": "^[0-9a-f]{40}$" },
        "rawFileUrl": { "type": "string", "format": "uri" },
        "localFile": { "type": "string", "minLength": 1 },
        "sha256": { "type": "string", "pattern": "^[0-9a-f]{64}$" },
        "interpolation": { "const": "linearBetweenAdjacentAuthorPackageLookupRows" }
      }
    },
    "exposure": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "unit",
        "mixedIntensityFormula",
        "moderateMarginalMET",
        "vigorousMarginalMET",
        "standardizedMixedMinutesToTotalVolumeSupported",
        "intensityMappingStatus",
        "interpretation",
        "separateIntensityHazardRatiosAvailable",
        "jointIntensityEffectSurfaceAvailable"
      ],
      "properties": {
        "unit": { "const": "marginalMETHourPerWeek" },
        "mixedIntensityFormula": { "type": "string", "minLength": 1 },
        "moderateMarginalMET": { "const": 3.5 },
        "vigorousMarginalMET": { "const": 7 },
        "standardizedMixedMinutesToTotalVolumeSupported": { "const": true },
        "intensityMappingStatus": { "const": "standardizedRepresentativeIntensityFromSource" },
        "interpretation": {
          "const": "standardizedTotalVolumeConversionNotSeparateOrJointIntensityEffect"
        },
        "separateIntensityHazardRatiosAvailable": { "const": false },
        "jointIntensityEffectSurfaceAvailable": { "const": false }
      }
    },
    "subgroupSpecificCurves": {
      "type": "object",
      "additionalProperties": false,
      "required": ["status", "age", "sex", "raceEthnicity"],
      "properties": {
        "status": { "const": "notAvailableForPublishedLookup" },
        "age": { "const": false },
        "sex": { "const": false },
        "raceEthnicity": { "const": false }
      }
    },
    "defaultCalculationRange": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "maximumMarginalMETHourPerWeek",
        "basis",
        "aboveRangePolicy",
        "maximumIsBiologicalEffectCeiling",
        "maximumWholeWeeklyMinutes"
      ],
      "properties": {
        "maximumMarginalMETHourPerWeek": { "type": "number", "exclusiveMinimum": 0 },
        "basis": { "const": "75thPercentileOfPersonYearsUsedByOfficialDrpaDefault" },
        "aboveRangePolicy": { "const": "clampToOfficialDrpa75thPercentile" },
        "maximumIsBiologicalEffectCeiling": { "const": false },
        "maximumWholeWeeklyMinutes": { "$ref": "#/$defs/minuteTotals" }
      }
    },
    "curvePoint": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "marginalMETHourPerWeek",
        "relativeRisk",
        "lowerConfidenceBound",
        "upperConfidenceBound"
      ],
      "properties": {
        "marginalMETHourPerWeek": { "type": "number", "minimum": 0 },
        "relativeRisk": { "type": "number", "exclusiveMinimum": 0 },
        "lowerConfidenceBound": { "type": "number", "exclusiveMinimum": 0 },
        "upperConfidenceBound": { "type": "number", "exclusiveMinimum": 0 }
      }
    },
    "minuteTotals": {
      "type": "object",
      "additionalProperties": false,
      "required": ["moderate", "vigorous"],
      "properties": {
        "moderate": { "type": "number", "minimum": 0 },
        "vigorous": { "type": "number", "minimum": 0 }
      }
    },
    "evaluation": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "requestedMarginalMETHourPerWeek",
        "evaluatedMarginalMETHourPerWeek",
        "cappedAtDefaultMaximum",
        "relativeRisk",
        "lowerConfidenceBound",
        "upperConfidenceBound",
        "relativeRiskDifferenceFromInactivePercent"
      ],
      "properties": {
        "requestedMarginalMETHourPerWeek": { "type": "number", "minimum": 0 },
        "evaluatedMarginalMETHourPerWeek": { "type": "number", "minimum": 0 },
        "cappedAtDefaultMaximum": { "type": "boolean" },
        "relativeRisk": { "type": "number", "exclusiveMinimum": 0 },
        "lowerConfidenceBound": { "type": "number", "exclusiveMinimum": 0 },
        "upperConfidenceBound": { "type": "number", "exclusiveMinimum": 0 },
        "relativeRiskDifferenceFromInactivePercent": { "type": "number" }
      }
    },
    "liveSessionInput": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "habitualDoseBeforeSession",
        "habitualDoseBeforeSessionDailyDecayAlreadyApplied",
        "habitualDoseBeforeSessionExcludesCurrentSession",
        "halfLifeDays",
        "currentSession"
      ],
      "properties": {
        "habitualDoseBeforeSession": { "type": "number", "minimum": 0 },
        "habitualDoseBeforeSessionDailyDecayAlreadyApplied": { "const": true },
        "habitualDoseBeforeSessionExcludesCurrentSession": { "const": true },
        "halfLifeDays": { "type": "number", "exclusiveMinimum": 0 },
        "currentSession": {
          "type": "object",
          "additionalProperties": false,
          "required": ["intensity", "elapsedQualifyingMinutes"],
          "properties": {
            "intensity": { "enum": ["moderate", "vigorous"] },
            "elapsedQualifyingMinutes": { "type": "integer", "minimum": 0 }
          }
        }
      }
    },
    "contrastIncrement": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "relativeRiskChange",
        "percentBelowInactiveReferenceIncreasePercentagePoints",
        "confidenceIntervalStatus"
      ],
      "properties": {
        "relativeRiskChange": { "type": "number" },
        "percentBelowInactiveReferenceIncreasePercentagePoints": { "type": "number" },
        "confidenceIntervalStatus": {
          "const": "notEstimableFromMarginalCurvePointIntervals"
        }
      }
    },
    "nextMinuteAvailable": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "status",
        "intensity",
        "projectedSessionMinute",
        "projectedPooledRelativeRisk",
        "relativeRiskChange",
        "percentBelowInactiveReferenceIncreasePercentagePoints",
        "confidenceIntervalStatus"
      ],
      "properties": {
        "status": { "const": "availableWithinConservativeDisplayRange" },
        "intensity": { "enum": ["moderate", "vigorous"] },
        "projectedSessionMinute": { "type": "number", "minimum": 1 },
        "projectedPooledRelativeRisk": { "type": "number", "exclusiveMinimum": 0 },
        "relativeRiskChange": { "type": "number" },
        "percentBelowInactiveReferenceIncreasePercentagePoints": { "type": "number" },
        "confidenceIntervalStatus": {
          "const": "notEstimableFromMarginalCurvePointIntervals"
        }
      }
    },
    "nextMinuteUnavailable": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "status",
        "intensity",
        "projectedSessionMinute",
        "projectedPooledRelativeRisk",
        "relativeRiskChange",
        "percentBelowInactiveReferenceIncreasePercentagePoints",
        "confidenceIntervalStatus"
      ],
      "properties": {
        "status": { "const": "unavailableAtConservativeDisplayLimit" },
        "intensity": { "enum": ["moderate", "vigorous"] },
        "projectedSessionMinute": { "type": "number", "minimum": 1 },
        "projectedPooledRelativeRisk": { "type": "null" },
        "relativeRiskChange": { "type": "null" },
        "percentBelowInactiveReferenceIncreasePercentagePoints": { "type": "null" },
        "confidenceIntervalStatus": {
          "const": "notEstimableFromMarginalCurvePointIntervals"
        }
      }
    },
    "liveFeedback": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "displayedImmediatelyFromSessionProgress",
        "elapsedSessionMinute",
        "currentHabitualDoseContrast",
        "sessionHabitualDoseContrastIncrement"
      ],
      "properties": {
        "displayedImmediatelyFromSessionProgress": { "const": true },
        "elapsedSessionMinute": { "type": "number", "minimum": 0 },
        "currentHabitualDoseContrast": {
          "type": "object",
          "additionalProperties": false,
          "required": ["pooledRelativeRisk", "percentBelowInactiveReference"],
          "properties": {
            "pooledRelativeRisk": { "type": "number", "exclusiveMinimum": 0 },
            "percentBelowInactiveReference": { "type": "number" }
          }
        },
        "sessionHabitualDoseContrastIncrement": { "$ref": "#/$defs/contrastIncrement" }
      }
    },
    "liveSessionResult": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "modelId",
        "calculationKind",
        "acuteBiologicalEffectClaimed",
        "causalEffectClaimed",
        "input",
        "smoothing",
        "habitualDoseIncludingCurrentSession",
        "pooledModelAtHabitualDoseBeforeSession",
        "pooledModelAtHabitualDoseIncludingSession",
        "liveFeedback",
        "nextMinuteDoseContrastIncrement"
      ],
      "properties": {
        "modelId": { "type": "string", "minLength": 1 },
        "calculationKind": { "const": "ewmaHabitualDoseCurrentSessionSnapshot" },
        "acuteBiologicalEffectClaimed": { "const": false },
        "causalEffectClaimed": { "const": false },
        "input": { "$ref": "#/$defs/liveSessionInput" },
        "smoothing": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "dailyRetention",
            "newDailyRecordWeight",
            "doseIncrementPerSessionMinute"
          ],
          "properties": {
            "dailyRetention": { "type": "number", "exclusiveMinimum": 0, "maximum": 1 },
            "newDailyRecordWeight": { "type": "number", "exclusiveMinimum": 0, "maximum": 1 },
            "doseIncrementPerSessionMinute": { "type": "number", "exclusiveMinimum": 0 }
          }
        },
        "habitualDoseIncludingCurrentSession": { "type": "number", "minimum": 0 },
        "pooledModelAtHabitualDoseBeforeSession": { "$ref": "#/$defs/evaluation" },
        "pooledModelAtHabitualDoseIncludingSession": { "$ref": "#/$defs/evaluation" },
        "liveFeedback": { "$ref": "#/$defs/liveFeedback" },
        "nextMinuteDoseContrastIncrement": {
          "oneOf": [
            { "$ref": "#/$defs/nextMinuteAvailable" },
            { "$ref": "#/$defs/nextMinuteUnavailable" }
          ]
        }
      }
    },
    "model": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "id",
        "outcome",
        "endpoint",
        "effectMeasure",
        "reference",
        "source",
        "observationContext",
        "curveData",
        "exposure",
        "subgroupSpecificCurves",
        "defaultCalculationRange",
        "sourceCurve",
        "limitations"
      ],
      "properties": {
        "id": { "type": "string", "minLength": 1 },
        "outcome": { "$ref": "#/$defs/localized" },
        "endpoint": { "$ref": "#/$defs/localized" },
        "effectMeasure": { "const": "relativeRisk" },
        "reference": { "$ref": "#/$defs/localized" },
        "source": { "$ref": "#/$defs/source" },
        "observationContext": { "$ref": "#/$defs/observationContext" },
        "curveData": { "$ref": "#/$defs/curveData" },
        "exposure": { "$ref": "#/$defs/exposure" },
        "subgroupSpecificCurves": { "$ref": "#/$defs/subgroupSpecificCurves" },
        "defaultCalculationRange": { "$ref": "#/$defs/defaultCalculationRange" },
        "sourceCurve": {
          "type": "array",
          "minItems": 2,
          "items": { "$ref": "#/$defs/curvePoint" }
        },
        "limitations": {
          "type": "array",
          "minItems": 1,
          "items": { "$ref": "#/$defs/localized" }
        }
      }
    },
    "workedExample": {
      "type": "object",
      "additionalProperties": false,
      "required": ["id", "description", "input", "results"],
      "properties": {
        "id": { "type": "string", "minLength": 1 },
        "description": { "$ref": "#/$defs/localized" },
        "input": { "$ref": "#/$defs/liveSessionInput" },
        "results": {
          "type": "array",
          "minItems": 1,
          "items": { "$ref": "#/$defs/liveSessionResult" }
        }
      }
    }
  }
}
