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


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

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

    actual_arm: str | None = Field(
        None, alias="actualArm", serialization_alias="actualArm"
    )
    assigned_arm: str | None = Field(
        None, alias="assignedArm", serialization_alias="assignedArm"
    )
    consent: Reference | None = Field(
        None, alias="consent", serialization_alias="consent"
    )
    identifier: PyList[Identifier] | None = Field(
        None, alias="identifier", serialization_alias="identifier"
    )
    individual: Reference = Field(alias="individual", serialization_alias="individual")
    period: Period | None = Field(None, alias="period", serialization_alias="period")
    status: Literal[
        "candidate",
        "eligible",
        "follow-up",
        "ineligible",
        "not-registered",
        "off-study",
        "on-study",
        "on-study-intervention",
        "on-study-observation",
        "pending-on-study",
        "potential-candidate",
        "screening",
        "withdrawn",
    ] = Field(alias="status", serialization_alias="status")
    study: Reference = Field(alias="study", serialization_alias="study")

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