# 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,
    CodeableConcept,
    Reference,
    Signature,
    Timing,
)
from fhirschemapy.R4B.domain_resource import DomainResource


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

    communication_method: CodeableConcept | None = Field(
        None, alias="communicationMethod", serialization_alias="communicationMethod"
    )
    date: str | None = Field(None, alias="date", serialization_alias="date")
    on_behalf_of: Reference | None = Field(
        None, alias="onBehalfOf", serialization_alias="onBehalfOf"
    )
    proxy_identity_certificate: str | None = Field(
        None,
        alias="proxyIdentityCertificate",
        serialization_alias="proxyIdentityCertificate",
    )
    proxy_signature: Signature | None = Field(
        None, alias="proxySignature", serialization_alias="proxySignature"
    )
    source_identity_certificate: str | None = Field(
        None,
        alias="sourceIdentityCertificate",
        serialization_alias="sourceIdentityCertificate",
    )
    source_signature: Signature | None = Field(
        None, alias="sourceSignature", serialization_alias="sourceSignature"
    )
    who: Reference | None = Field(None, alias="who", serialization_alias="who")


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

    can_push_updates: CodeableConcept | None = Field(
        None, alias="canPushUpdates", serialization_alias="canPushUpdates"
    )
    communication_method: PyList[CodeableConcept] | None = Field(
        None, alias="communicationMethod", serialization_alias="communicationMethod"
    )
    push_type_available: PyList[CodeableConcept] | None = Field(
        None, alias="pushTypeAvailable", serialization_alias="pushTypeAvailable"
    )
    type: PyList[CodeableConcept] | None = Field(
        None, alias="type", serialization_alias="type"
    )
    validation_date: str | None = Field(
        None, alias="validationDate", serialization_alias="validationDate"
    )
    validation_status: CodeableConcept | None = Field(
        None, alias="validationStatus", serialization_alias="validationStatus"
    )
    who: Reference | None = Field(None, alias="who", serialization_alias="who")


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

    attestation_signature: Signature | None = Field(
        None, alias="attestationSignature", serialization_alias="attestationSignature"
    )
    identity_certificate: str | None = Field(
        None, alias="identityCertificate", serialization_alias="identityCertificate"
    )
    organization: Reference = Field(
        alias="organization", serialization_alias="organization"
    )


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

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

    attestation: VerificationResultAttestation | None = Field(
        None, alias="attestation", serialization_alias="attestation"
    )
    failure_action: CodeableConcept | None = Field(
        None, alias="failureAction", serialization_alias="failureAction"
    )
    frequency: Timing | None = Field(
        None, alias="frequency", serialization_alias="frequency"
    )
    last_performed: str | None = Field(
        None, alias="lastPerformed", serialization_alias="lastPerformed"
    )
    need: CodeableConcept | None = Field(None, alias="need", serialization_alias="need")
    next_scheduled: str | None = Field(
        None, alias="nextScheduled", serialization_alias="nextScheduled"
    )
    primary_source: PyList[VerificationResultPrimarySource] | None = Field(
        None, alias="primarySource", serialization_alias="primarySource"
    )
    status: Literal[
        "attested", "validated", "in-process", "req-revalid", "val-fail", "reval-fail"
    ] = Field(alias="status", serialization_alias="status")
    status_date: str | None = Field(
        None, alias="statusDate", serialization_alias="statusDate"
    )
    target: PyList[Reference] | None = Field(
        None, alias="target", serialization_alias="target"
    )
    target_location: PyList[str] | None = Field(
        None, alias="targetLocation", serialization_alias="targetLocation"
    )
    validation_process: PyList[CodeableConcept] | None = Field(
        None, alias="validationProcess", serialization_alias="validationProcess"
    )
    validation_type: CodeableConcept | None = Field(
        None, alias="validationType", serialization_alias="validationType"
    )
    validator: PyList[VerificationResultValidator] | None = Field(
        None, alias="validator", serialization_alias="validator"
    )

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