"""
Auto-generated Python types from spec/schema.json
Generated: 2025-12-11T18:16:44.345231

DO NOT EDIT - Regenerate with: python tools/codegen.py --types
"""

# generated by datamodel-codegen:
#   filename:  schema.json
#   timestamp: 2025-12-11T23:16:44+00:00

from __future__ import annotations

from dataclasses import dataclass
from enum import Enum
from typing import Dict, List, Optional, Union

from typing_extensions import TypeAlias

ScenarioName: TypeAlias = str


SemanticVersion: TypeAlias = str


Identifier: TypeAlias = str


@dataclass
class PopulationFilter:
    include: Optional[List[str]] = None
    exclude: Optional[List[str]] = None


class SignalType(Enum):
    numeric = "numeric"
    categorical = "categorical"
    boolean = "boolean"
    datetime = "datetime"


class OMOPDomain(Enum):
    measurement = "measurement"
    condition = "condition"
    drug = "drug"
    procedure = "procedure"
    observation = "observation"
    device = "device"
    specimen = "specimen"


TrendExpression: TypeAlias = str


LogicExpression: TypeAlias = str


class SeverityLevel(Enum):
    low = "low"
    medium = "medium"
    high = "high"
    critical = "critical"


@dataclass
class ConceptMapping:
    concept_id: Optional[int] = None
    table: Optional[str] = None
    value_column: Optional[str] = None
    datetime_column: Optional[str] = None


class ValidationStatus(Enum):
    draft = "draft"
    validated = "validated"
    clinical_review = "clinical_review"
    production = "production"


@dataclass
class ScenarioMetadata:
    created: Optional[str] = None
    updated: Optional[str] = None
    references: Optional[List[str]] = None
    validation_status: Optional[ValidationStatus] = None
    icd10_codes: Optional[List[str]] = None
    snomed_codes: Optional[List[str]] = None


Window: TypeAlias = str


class WindowedOperator(Enum):
    delta = "delta"
    slope = "slope"
    sma = "sma"
    ema = "ema"
    min = "min"
    max = "max"
    count = "count"
    first = "first"
    std = "std"
    stddev = "stddev"
    percentile = "percentile"


class PointwiseOperator(Enum):
    last = "last"
    exists = "exists"
    missing = "missing"


class ComparisonOperator(Enum):
    field__ = "=="
    field___1 = "!="
    field_ = "<"
    field___2 = "<="
    field__1 = ">"
    field___3 = ">="


class BooleanOperator(Enum):
    AND = "AND"
    OR = "OR"
    NOT = "NOT"


@dataclass
class SignalSpec1:
    source: str
    type: Optional[SignalType] = SignalType.numeric
    concept_id: Optional[int] = None
    unit: Optional[str] = None
    domain: Optional[OMOPDomain] = OMOPDomain.measurement
    description: Optional[str] = None


SignalSpec: TypeAlias = Union[str, SignalSpec1]


@dataclass
class TrendSpec1:
    expr: TrendExpression
    description: Optional[str] = None


TrendSpec: TypeAlias = Union[TrendExpression, TrendSpec1]


@dataclass
class LogicSpec1:
    expr: LogicExpression
    severity: Optional[SeverityLevel] = None
    description: Optional[str] = None
    recommendation: Optional[str] = None


LogicSpec: TypeAlias = Union[LogicExpression, LogicSpec1]


@dataclass
class MappingConfig:
    source: Optional[str] = None
    inline: Optional[Dict[str, ConceptMapping]] = None


SignalDefinitions: TypeAlias = Dict[str, SignalSpec]


TrendDefinitions: TypeAlias = Dict[str, TrendSpec]


LogicDefinitions: TypeAlias = Dict[str, LogicSpec]


@dataclass
class PsdlScenarioSchemaV02:
    scenario: ScenarioName
    version: SemanticVersion
    signals: SignalDefinitions
    logic: LogicDefinitions
    name: Optional[str] = None
    description: Optional[str] = None
    author: Optional[str] = None
    tags: Optional[List[str]] = None
    population: Optional[PopulationFilter] = None
    trends: Optional[TrendDefinitions] = None
    mapping: Optional[MappingConfig] = None
    metadata: Optional[ScenarioMetadata] = None
