# 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 BackboneElement, Identifier, Reference
from fhirschemapy.R4B.domain_resource import DomainResource


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

    display: str | None = Field(None, alias="display", serialization_alias="display")
    type: Literal["test-engine", "client", "server"] = Field(
        alias="type", serialization_alias="type"
    )
    uri: str = Field(alias="uri", serialization_alias="uri")


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

    action: PyList[TestReportSetupAction] = Field(
        alias="action", serialization_alias="action"
    )


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

    assert_: TestReportSetupActionAssert | None = Field(
        None, alias="assert", serialization_alias="assert"
    )
    operation: TestReportSetupActionOperation | None = Field(
        None, alias="operation", serialization_alias="operation"
    )


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

    detail: str | None = Field(None, alias="detail", serialization_alias="detail")
    message: str | None = Field(None, alias="message", serialization_alias="message")
    result: Literal["pass", "skip", "fail", "warning", "error"] = Field(
        alias="result", serialization_alias="result"
    )


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

    detail: str | None = Field(None, alias="detail", serialization_alias="detail")
    message: str | None = Field(None, alias="message", serialization_alias="message")
    result: Literal["pass", "skip", "fail", "warning", "error"] = Field(
        alias="result", serialization_alias="result"
    )


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

    action: PyList[TestReportTeardownAction] = Field(
        alias="action", serialization_alias="action"
    )


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

    operation: TestReportSetupActionOperation = Field(
        alias="operation", serialization_alias="operation"
    )


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

    action: PyList[TestReportTestAction] = Field(
        alias="action", serialization_alias="action"
    )
    description: str | None = Field(
        None, alias="description", serialization_alias="description"
    )
    name: str | None = Field(None, alias="name", serialization_alias="name")


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

    assert_: TestReportSetupActionAssert | None = Field(
        None, alias="assert", serialization_alias="assert"
    )
    operation: TestReportSetupActionOperation | None = Field(
        None, alias="operation", serialization_alias="operation"
    )


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

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

    identifier: Identifier | None = Field(
        None, alias="identifier", serialization_alias="identifier"
    )
    issued: str | None = Field(None, alias="issued", serialization_alias="issued")
    name: str | None = Field(None, alias="name", serialization_alias="name")
    participant: PyList[TestReportParticipant] | None = Field(
        None, alias="participant", serialization_alias="participant"
    )
    result: Literal["pass", "fail", "pending"] = Field(
        alias="result", serialization_alias="result"
    )
    score: float | None = Field(None, alias="score", serialization_alias="score")
    setup: TestReportSetup | None = Field(
        None, alias="setup", serialization_alias="setup"
    )
    status: Literal[
        "completed", "in-progress", "waiting", "stopped", "entered-in-error"
    ] = Field(alias="status", serialization_alias="status")
    teardown: TestReportTeardown | None = Field(
        None, alias="teardown", serialization_alias="teardown"
    )
    test: PyList[TestReportTest] | None = Field(
        None, alias="test", serialization_alias="test"
    )
    tester: str | None = Field(None, alias="tester", serialization_alias="tester")
    test_script: Reference = Field(alias="testScript", serialization_alias="testScript")

    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) -> TestReport:
        return cls.model_validate_json(json)
