# WARNING: This file is autogenerated by FHIR Schema Codegen.
# https://github.com/fhir-schema/fhir-schema-codegen
# Any manual changes made to this file may be overwritten.

from __future__ import annotations
from pydantic import ConfigDict, Field
from typing import List as PyList, Literal

from fhirschemapy.R4B.base import (
    Annotation,
    BackboneElement,
    CodeableConcept,
    ContactDetail,
    DataRequirement,
    Duration,
    Expression,
    Identifier,
    Period,
    Reference,
    RelatedArtifact,
    Timing,
    TriggerDefinition,
    UsageContext,
)
from fhirschemapy.R4B.domain_resource import DomainResource


class EvidenceVariableCharacteristic(BackboneElement):
    model_config = ConfigDict(serialize_by_alias=True, extra="forbid")

    definition_canonical: str | None = Field(
        None, alias="definitionCanonical", serialization_alias="definitionCanonical"
    )
    definition_codeable_concept: CodeableConcept | None = Field(
        None,
        alias="definitionCodeableConcept",
        serialization_alias="definitionCodeableConcept",
    )
    definition_data_requirement: DataRequirement | None = Field(
        None,
        alias="definitionDataRequirement",
        serialization_alias="definitionDataRequirement",
    )
    definition_expression: Expression | None = Field(
        None, alias="definitionExpression", serialization_alias="definitionExpression"
    )
    definition_reference: Reference | None = Field(
        None, alias="definitionReference", serialization_alias="definitionReference"
    )
    definition_trigger_definition: TriggerDefinition | None = Field(
        None,
        alias="definitionTriggerDefinition",
        serialization_alias="definitionTriggerDefinition",
    )
    description: str | None = Field(
        None, alias="description", serialization_alias="description"
    )
    exclude: bool | None = Field(None, alias="exclude", serialization_alias="exclude")
    group_measure: (
        Literal[
            "mean",
            "median",
            "mean-of-mean",
            "mean-of-median",
            "median-of-mean",
            "median-of-median",
        ]
        | None
    ) = Field(None, alias="groupMeasure", serialization_alias="groupMeasure")
    participant_effective_date_time: str | None = Field(
        None,
        alias="participantEffectiveDateTime",
        serialization_alias="participantEffectiveDateTime",
    )
    participant_effective_duration: Duration | None = Field(
        None,
        alias="participantEffectiveDuration",
        serialization_alias="participantEffectiveDuration",
    )
    participant_effective_period: Period | None = Field(
        None,
        alias="participantEffectivePeriod",
        serialization_alias="participantEffectivePeriod",
    )
    participant_effective_timing: Timing | None = Field(
        None,
        alias="participantEffectiveTiming",
        serialization_alias="participantEffectiveTiming",
    )
    time_from_start: Duration | None = Field(
        None, alias="timeFromStart", serialization_alias="timeFromStart"
    )
    usage_context: PyList[UsageContext] | None = Field(
        None, alias="usageContext", serialization_alias="usageContext"
    )


class EvidenceVariable(DomainResource):
    model_config = ConfigDict(serialize_by_alias=True, extra="forbid")

    resource_type: str = Field(
        default="EvidenceVariable",
        alias="resourceType",
        serialization_alias="resourceType",
        frozen=True,
        pattern="EvidenceVariable",
    )

    approval_date: str | None = Field(
        None, alias="approvalDate", serialization_alias="approvalDate"
    )
    author: PyList[ContactDetail] | None = Field(
        None, alias="author", serialization_alias="author"
    )
    characteristic: PyList[EvidenceVariableCharacteristic] = Field(
        alias="characteristic", serialization_alias="characteristic"
    )
    contact: PyList[ContactDetail] | None = Field(
        None, alias="contact", serialization_alias="contact"
    )
    copyright: str | None = Field(
        None, alias="copyright", serialization_alias="copyright"
    )
    date: str | None = Field(None, alias="date", serialization_alias="date")
    description: str | None = Field(
        None, alias="description", serialization_alias="description"
    )
    editor: PyList[ContactDetail] | None = Field(
        None, alias="editor", serialization_alias="editor"
    )
    effective_period: Period | None = Field(
        None, alias="effectivePeriod", serialization_alias="effectivePeriod"
    )
    endorser: PyList[ContactDetail] | None = Field(
        None, alias="endorser", serialization_alias="endorser"
    )
    identifier: PyList[Identifier] | None = Field(
        None, alias="identifier", serialization_alias="identifier"
    )
    jurisdiction: PyList[CodeableConcept] | None = Field(
        None, alias="jurisdiction", serialization_alias="jurisdiction"
    )
    last_review_date: str | None = Field(
        None, alias="lastReviewDate", serialization_alias="lastReviewDate"
    )
    name: str | None = Field(None, alias="name", serialization_alias="name")
    note: PyList[Annotation] | None = Field(
        None, alias="note", serialization_alias="note"
    )
    publisher: str | None = Field(
        None, alias="publisher", serialization_alias="publisher"
    )
    related_artifact: PyList[RelatedArtifact] | None = Field(
        None, alias="relatedArtifact", serialization_alias="relatedArtifact"
    )
    reviewer: PyList[ContactDetail] | None = Field(
        None, alias="reviewer", serialization_alias="reviewer"
    )
    short_title: str | None = Field(
        None, alias="shortTitle", serialization_alias="shortTitle"
    )
    status: Literal["draft", "active", "retired", "unknown"] = Field(
        alias="status", serialization_alias="status"
    )
    subtitle: str | None = Field(None, alias="subtitle", serialization_alias="subtitle")
    title: str | None = Field(None, alias="title", serialization_alias="title")
    topic: PyList[CodeableConcept] | None = Field(
        None, alias="topic", serialization_alias="topic"
    )
    type: Literal["dichotomous", "continuous", "descriptive"] | None = Field(
        None, alias="type", serialization_alias="type"
    )
    url: str | None = Field(None, alias="url", serialization_alias="url")
    use_context: PyList[UsageContext] | None = Field(
        None, alias="useContext", serialization_alias="useContext"
    )
    version: str | None = Field(None, alias="version", serialization_alias="version")

    def to_json(self, indent: int | None = None) -> str:
        return self.model_dump_json(
            exclude_unset=True, exclude_none=True, indent=indent
        )

    @classmethod
    def from_json(cls, json: str) -> EvidenceVariable:
        return cls.model_validate_json(json)
