{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://schemas.vik.guru/investment-analysis/0.2.0/state.schema.json",
  "title": "Investment analysis state 0.2.0",
  "description": "Validation-input contract for portable investment analysis state; generated by core.js.",
  "type": "object",
  "additionalProperties": false,
  "properties": {
    "schemaVersion": {
      "const": "0.2.0"
    },
    "scenarioId": {
      "type": "string",
      "minLength": 1,
      "maxLength": 200
    },
    "method": {
      "type": "string",
      "maxLength": 2000
    },
    "origin": {
      "enum": [
        "illustrative",
        "user-supplied",
        "observed"
      ]
    },
    "inputs": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "label": {
          "type": "string",
          "maxLength": 2000
        },
        "currency": {
          "type": "string",
          "maxLength": 2000
        },
        "period": {
          "enum": [
            "month",
            "quarter",
            "year"
          ]
        },
        "segment": {
          "type": "string",
          "maxLength": 2000
        },
        "cohort": {
          "type": "string",
          "maxLength": 2000
        },
        "tenure": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            },
            {
              "type": "string",
              "maxLength": 128,
              "pattern": "^(?:\\s*[+-]?(?:[0-9]+(?:\\.[0-9]*)?|\\.[0-9]+)(?:[eE][+-]?[0-9]+)?\\s*|\\s*)$"
            }
          ]
        },
        "implementationState": {
          "type": "string",
          "maxLength": 2000
        },
        "openingCustomers": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            },
            {
              "type": "string",
              "maxLength": 128,
              "pattern": "^(?:\\s*[+-]?(?:[0-9]+(?:\\.[0-9]*)?|\\.[0-9]+)(?:[eE][+-]?[0-9]+)?\\s*|\\s*)$"
            }
          ]
        },
        "newCustomers": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            },
            {
              "type": "string",
              "maxLength": 128,
              "pattern": "^(?:\\s*[+-]?(?:[0-9]+(?:\\.[0-9]*)?|\\.[0-9]+)(?:[eE][+-]?[0-9]+)?\\s*|\\s*)$"
            }
          ]
        },
        "churnCustomers": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            },
            {
              "type": "string",
              "maxLength": 128,
              "pattern": "^(?:\\s*[+-]?(?:[0-9]+(?:\\.[0-9]*)?|\\.[0-9]+)(?:[eE][+-]?[0-9]+)?\\s*|\\s*)$"
            }
          ]
        },
        "reactivatedCustomers": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            },
            {
              "type": "string",
              "maxLength": 128,
              "pattern": "^(?:\\s*[+-]?(?:[0-9]+(?:\\.[0-9]*)?|\\.[0-9]+)(?:[eE][+-]?[0-9]+)?\\s*|\\s*)$"
            }
          ]
        },
        "openingRevenue": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            },
            {
              "type": "string",
              "maxLength": 128,
              "pattern": "^(?:\\s*[+-]?(?:[0-9]+(?:\\.[0-9]*)?|\\.[0-9]+)(?:[eE][+-]?[0-9]+)?\\s*|\\s*)$"
            }
          ]
        },
        "churnRevenue": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            },
            {
              "type": "string",
              "maxLength": 128,
              "pattern": "^(?:\\s*[+-]?(?:[0-9]+(?:\\.[0-9]*)?|\\.[0-9]+)(?:[eE][+-]?[0-9]+)?\\s*|\\s*)$"
            }
          ]
        },
        "contraction": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            },
            {
              "type": "string",
              "maxLength": 128,
              "pattern": "^(?:\\s*[+-]?(?:[0-9]+(?:\\.[0-9]*)?|\\.[0-9]+)(?:[eE][+-]?[0-9]+)?\\s*|\\s*)$"
            }
          ]
        },
        "expansion": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            },
            {
              "type": "string",
              "maxLength": 128,
              "pattern": "^(?:\\s*[+-]?(?:[0-9]+(?:\\.[0-9]*)?|\\.[0-9]+)(?:[eE][+-]?[0-9]+)?\\s*|\\s*)$"
            }
          ]
        },
        "newRevenue": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            },
            {
              "type": "string",
              "maxLength": 128,
              "pattern": "^(?:\\s*[+-]?(?:[0-9]+(?:\\.[0-9]*)?|\\.[0-9]+)(?:[eE][+-]?[0-9]+)?\\s*|\\s*)$"
            }
          ]
        },
        "reactivationRevenue": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            },
            {
              "type": "string",
              "maxLength": 128,
              "pattern": "^(?:\\s*[+-]?(?:[0-9]+(?:\\.[0-9]*)?|\\.[0-9]+)(?:[eE][+-]?[0-9]+)?\\s*|\\s*)$"
            }
          ]
        },
        "acquisitionSpend": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            },
            {
              "type": "string",
              "maxLength": 128,
              "pattern": "^(?:\\s*[+-]?(?:[0-9]+(?:\\.[0-9]*)?|\\.[0-9]+)(?:[eE][+-]?[0-9]+)?\\s*|\\s*)$"
            }
          ]
        },
        "contributionMargin": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            },
            {
              "type": "string",
              "maxLength": 128,
              "pattern": "^(?:\\s*[+-]?(?:[0-9]+(?:\\.[0-9]*)?|\\.[0-9]+)(?:[eE][+-]?[0-9]+)?\\s*|\\s*)$"
            }
          ]
        },
        "listPrice": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            },
            {
              "type": "string",
              "maxLength": 128,
              "pattern": "^(?:\\s*[+-]?(?:[0-9]+(?:\\.[0-9]*)?|\\.[0-9]+)(?:[eE][+-]?[0-9]+)?\\s*|\\s*)$"
            }
          ]
        },
        "discount": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            },
            {
              "type": "string",
              "maxLength": 128,
              "pattern": "^(?:\\s*[+-]?(?:[0-9]+(?:\\.[0-9]*)?|\\.[0-9]+)(?:[eE][+-]?[0-9]+)?\\s*|\\s*)$"
            }
          ]
        },
        "rebate": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            },
            {
              "type": "string",
              "maxLength": 128,
              "pattern": "^(?:\\s*[+-]?(?:[0-9]+(?:\\.[0-9]*)?|\\.[0-9]+)(?:[eE][+-]?[0-9]+)?\\s*|\\s*)$"
            }
          ]
        },
        "variableCost": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            },
            {
              "type": "string",
              "maxLength": 128,
              "pattern": "^(?:\\s*[+-]?(?:[0-9]+(?:\\.[0-9]*)?|\\.[0-9]+)(?:[eE][+-]?[0-9]+)?\\s*|\\s*)$"
            }
          ]
        },
        "serviceCost": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            },
            {
              "type": "string",
              "maxLength": 128,
              "pattern": "^(?:\\s*[+-]?(?:[0-9]+(?:\\.[0-9]*)?|\\.[0-9]+)(?:[eE][+-]?[0-9]+)?\\s*|\\s*)$"
            }
          ]
        },
        "pricingUnit": {
          "type": "string",
          "maxLength": 2000
        },
        "buyer": {
          "type": "string",
          "maxLength": 2000
        },
        "priceClass": {
          "enum": [
            "Illustrative scenario",
            "Public cash-pay price",
            "Contracted price",
            "Observed realized revenue"
          ]
        },
        "implementationCost": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            },
            {
              "type": "string",
              "maxLength": 128,
              "pattern": "^(?:\\s*[+-]?(?:[0-9]+(?:\\.[0-9]*)?|\\.[0-9]+)(?:[eE][+-]?[0-9]+)?\\s*|\\s*)$"
            }
          ]
        },
        "implementationLag": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            },
            {
              "type": "string",
              "maxLength": 128,
              "pattern": "^(?:\\s*[+-]?(?:[0-9]+(?:\\.[0-9]*)?|\\.[0-9]+)(?:[eE][+-]?[0-9]+)?\\s*|\\s*)$"
            }
          ]
        },
        "internalInvestment": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            },
            {
              "type": "string",
              "maxLength": 128,
              "pattern": "^(?:\\s*[+-]?(?:[0-9]+(?:\\.[0-9]*)?|\\.[0-9]+)(?:[eE][+-]?[0-9]+)?\\s*|\\s*)$"
            }
          ]
        },
        "discountRate": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            },
            {
              "type": "string",
              "maxLength": 128,
              "pattern": "^(?:\\s*[+-]?(?:[0-9]+(?:\\.[0-9]*)?|\\.[0-9]+)(?:[eE][+-]?[0-9]+)?\\s*|\\s*)$"
            }
          ]
        },
        "cashConvention": {
          "type": "string",
          "maxLength": 2000
        },
        "taxWorkingCapital": {
          "type": "string",
          "maxLength": 2000
        },
        "capacity": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            },
            {
              "type": "string",
              "maxLength": 128,
              "pattern": "^(?:\\s*[+-]?(?:[0-9]+(?:\\.[0-9]*)?|\\.[0-9]+)(?:[eE][+-]?[0-9]+)?\\s*|\\s*)$"
            }
          ]
        },
        "exhaustive": {
          "type": "boolean"
        },
        "eligiblePopulation": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            },
            {
              "type": "string",
              "maxLength": 128,
              "pattern": "^(?:\\s*[+-]?(?:[0-9]+(?:\\.[0-9]*)?|\\.[0-9]+)(?:[eE][+-]?[0-9]+)?\\s*|\\s*)$"
            }
          ]
        },
        "adoption": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            },
            {
              "type": "string",
              "maxLength": 128,
              "pattern": "^(?:\\s*[+-]?(?:[0-9]+(?:\\.[0-9]*)?|\\.[0-9]+)(?:[eE][+-]?[0-9]+)?\\s*|\\s*)$"
            }
          ]
        },
        "baselineCost": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            },
            {
              "type": "string",
              "maxLength": 128,
              "pattern": "^(?:\\s*[+-]?(?:[0-9]+(?:\\.[0-9]*)?|\\.[0-9]+)(?:[eE][+-]?[0-9]+)?\\s*|\\s*)$"
            }
          ]
        },
        "candidateCost": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            },
            {
              "type": "string",
              "maxLength": 128,
              "pattern": "^(?:\\s*[+-]?(?:[0-9]+(?:\\.[0-9]*)?|\\.[0-9]+)(?:[eE][+-]?[0-9]+)?\\s*|\\s*)$"
            }
          ]
        },
        "perspective": {
          "type": "string",
          "maxLength": 2000
        },
        "population": {
          "type": "string",
          "maxLength": 2000
        },
        "intervention": {
          "type": "string",
          "maxLength": 2000
        },
        "comparator": {
          "type": "string",
          "maxLength": 2000
        },
        "reviewer": {
          "type": "string",
          "maxLength": 2000
        },
        "evidenceSource": {
          "type": "string",
          "maxLength": 2000
        },
        "asOf": {
          "type": "string",
          "maxLength": 2000
        },
        "economicReview": {
          "enum": [
            "pending",
            "reviewed"
          ]
        },
        "incrementalOutcome": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            },
            {
              "type": "string",
              "maxLength": 128,
              "pattern": "^(?:\\s*[+-]?(?:[0-9]+(?:\\.[0-9]*)?|\\.[0-9]+)(?:[eE][+-]?[0-9]+)?\\s*|\\s*)$"
            }
          ]
        },
        "outcomeUnit": {
          "type": "string",
          "maxLength": 2000
        },
        "owner": {
          "type": "string",
          "maxLength": 2000
        },
        "trigger": {
          "type": "string",
          "maxLength": 2000
        },
        "nextEvidence": {
          "type": "string",
          "maxLength": 2000
        },
        "revisit": {
          "type": "string",
          "maxLength": 2000
        },
        "option": {
          "enum": [
            "status-quo",
            "proceed",
            "defer",
            "pilot",
            "scale",
            "redirect",
            "stop"
          ]
        },
        "gate": {
          "enum": [
            "open",
            "satisfied",
            "stop"
          ]
        }
      },
      "required": [
        "label",
        "currency",
        "period",
        "segment",
        "cohort",
        "tenure",
        "implementationState",
        "openingCustomers",
        "newCustomers",
        "churnCustomers",
        "reactivatedCustomers",
        "openingRevenue",
        "churnRevenue",
        "contraction",
        "expansion",
        "newRevenue",
        "reactivationRevenue",
        "acquisitionSpend",
        "contributionMargin",
        "listPrice",
        "discount",
        "rebate",
        "variableCost",
        "serviceCost",
        "pricingUnit",
        "buyer",
        "priceClass",
        "implementationCost",
        "implementationLag",
        "internalInvestment",
        "discountRate",
        "cashConvention",
        "taxWorkingCapital",
        "capacity",
        "exhaustive",
        "eligiblePopulation",
        "adoption",
        "baselineCost",
        "candidateCost",
        "perspective",
        "population",
        "intervention",
        "comparator",
        "reviewer",
        "evidenceSource",
        "asOf",
        "economicReview",
        "incrementalOutcome",
        "outcomeUnit",
        "owner",
        "trigger",
        "nextEvidence",
        "revisit",
        "option",
        "gate"
      ]
    },
    "alternatives": {
      "type": "array",
      "minItems": 1,
      "maxItems": 12,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "id": {
            "type": "string",
            "maxLength": 2000
          },
          "label": {
            "type": "string",
            "maxLength": 2000
          },
          "flows": {
            "type": "array",
            "minItems": 2,
            "maxItems": 101,
            "items": {
              "anyOf": [
                {
                  "type": "number"
                },
                {
                  "type": "null"
                },
                {
                  "type": "string",
                  "maxLength": 128,
                  "pattern": "^(?:\\s*[+-]?(?:[0-9]+(?:\\.[0-9]*)?|\\.[0-9]+)(?:[eE][+-]?[0-9]+)?\\s*|\\s*)$"
                }
              ]
            }
          },
          "standing": {
            "enum": [
              "illustrative",
              "user-supplied",
              "observed"
            ]
          }
        },
        "required": [
          "id",
          "label",
          "flows",
          "standing"
        ]
      }
    },
    "outcomes": {
      "type": "array",
      "minItems": 1,
      "maxItems": 12,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "id": {
            "type": "string",
            "maxLength": 2000
          },
          "probability": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              },
              {
                "type": "string",
                "maxLength": 128,
                "pattern": "^(?:\\s*[+-]?(?:[0-9]+(?:\\.[0-9]*)?|\\.[0-9]+)(?:[eE][+-]?[0-9]+)?\\s*|\\s*)$"
              }
            ]
          },
          "flows": {
            "type": "array",
            "minItems": 2,
            "maxItems": 101,
            "items": {
              "anyOf": [
                {
                  "type": "number"
                },
                {
                  "type": "null"
                },
                {
                  "type": "string",
                  "maxLength": 128,
                  "pattern": "^(?:\\s*[+-]?(?:[0-9]+(?:\\.[0-9]*)?|\\.[0-9]+)(?:[eE][+-]?[0-9]+)?\\s*|\\s*)$"
                }
              ]
            }
          }
        },
        "required": [
          "id",
          "probability",
          "flows"
        ]
      }
    },
    "serviceOutcomes": {
      "type": "array",
      "minItems": 9,
      "maxItems": 9,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "name": {
            "enum": [
              "Safety",
              "Quality",
              "Timeliness",
              "Patient experience",
              "Equity",
              "Efficiency",
              "Burden",
              "Governance",
              "Budget capacity"
            ]
          },
          "unit": {
            "type": "string",
            "maxLength": 2000
          },
          "baseline": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              },
              {
                "type": "string",
                "maxLength": 128,
                "pattern": "^(?:\\s*[+-]?(?:[0-9]+(?:\\.[0-9]*)?|\\.[0-9]+)(?:[eE][+-]?[0-9]+)?\\s*|\\s*)$"
              }
            ]
          },
          "candidate": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              },
              {
                "type": "string",
                "maxLength": 128,
                "pattern": "^(?:\\s*[+-]?(?:[0-9]+(?:\\.[0-9]*)?|\\.[0-9]+)(?:[eE][+-]?[0-9]+)?\\s*|\\s*)$"
              }
            ]
          },
          "standing": {
            "enum": [
              "unavailable",
              "illustrative",
              "source-observation",
              "transfer-hypothesis",
              "locally-verified"
            ]
          },
          "source": {
            "type": "string",
            "maxLength": 2000
          }
        },
        "required": [
          "name",
          "unit",
          "baseline",
          "candidate",
          "standing",
          "source"
        ]
      }
    },
    "events": {
      "type": "array",
      "maxItems": 100,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "id": {
            "type": "string",
            "maxLength": 2000
          },
          "kind": {
            "type": "string",
            "maxLength": 2000
          },
          "period": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              },
              {
                "type": "string",
                "maxLength": 128,
                "pattern": "^(?:\\s*[+-]?(?:[0-9]+(?:\\.[0-9]*)?|\\.[0-9]+)(?:[eE][+-]?[0-9]+)?\\s*|\\s*)$"
              }
            ]
          },
          "predecessors": {
            "type": "array",
            "maxItems": 100,
            "items": {
              "type": "string",
              "maxLength": 2000
            }
          },
          "standing": {
            "type": "string",
            "maxLength": 2000
          }
        },
        "required": [
          "id",
          "kind",
          "period",
          "predecessors",
          "standing"
        ]
      }
    },
    "extensions": {
      "type": "object",
      "propertyNames": {
        "pattern": "^urn:[a-zA-Z0-9][a-zA-Z0-9:._/-]*$"
      },
      "additionalProperties": true
    }
  },
  "required": [
    "schemaVersion",
    "scenarioId",
    "method",
    "origin",
    "inputs",
    "alternatives",
    "outcomes",
    "serviceOutcomes",
    "events",
    "extensions"
  ]
}
