# 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

from fhirschemapy.R4B.base import (
    Attachment,
    BackboneElement,
    CodeableConcept,
    Identifier,
)
from fhirschemapy.R4B.domain_resource import DomainResource


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

    c_terminal_modification: str | None = Field(
        None, alias="cTerminalModification", serialization_alias="cTerminalModification"
    )
    c_terminal_modification_id: Identifier | None = Field(
        None,
        alias="cTerminalModificationId",
        serialization_alias="cTerminalModificationId",
    )
    length: int | None = Field(None, alias="length", serialization_alias="length")
    n_terminal_modification: str | None = Field(
        None, alias="nTerminalModification", serialization_alias="nTerminalModification"
    )
    n_terminal_modification_id: Identifier | None = Field(
        None,
        alias="nTerminalModificationId",
        serialization_alias="nTerminalModificationId",
    )
    sequence: str | None = Field(None, alias="sequence", serialization_alias="sequence")
    sequence_attachment: Attachment | None = Field(
        None, alias="sequenceAttachment", serialization_alias="sequenceAttachment"
    )
    subunit: int | None = Field(None, alias="subunit", serialization_alias="subunit")


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

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

    disulfide_linkage: PyList[str] | None = Field(
        None, alias="disulfideLinkage", serialization_alias="disulfideLinkage"
    )
    number_of_subunits: int | None = Field(
        None, alias="numberOfSubunits", serialization_alias="numberOfSubunits"
    )
    sequence_type: CodeableConcept | None = Field(
        None, alias="sequenceType", serialization_alias="sequenceType"
    )
    subunit: PyList[SubstanceProteinSubunit] | None = Field(
        None, alias="subunit", serialization_alias="subunit"
    )

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