# 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 (
    Attachment,
    CodeableConcept,
    ContactDetail,
    DataRequirement,
    Identifier,
    ParameterDefinition,
    Period,
    Reference,
    RelatedArtifact,
    UsageContext,
)
from fhirschemapy.R4B.domain_resource import DomainResource


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

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

    approval_date: str | None = Field(
        None, alias="approvalDate", serialization_alias="approvalDate"
    )
    author: PyList[ContactDetail] | None = Field(
        None, alias="author", serialization_alias="author"
    )
    contact: PyList[ContactDetail] | None = Field(
        None, alias="contact", serialization_alias="contact"
    )
    content: PyList[Attachment] | None = Field(
        None, alias="content", serialization_alias="content"
    )
    copyright: str | None = Field(
        None, alias="copyright", serialization_alias="copyright"
    )
    data_requirement: PyList[DataRequirement] | None = Field(
        None, alias="dataRequirement", serialization_alias="dataRequirement"
    )
    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"
    )
    experimental: bool | None = Field(
        None, alias="experimental", serialization_alias="experimental"
    )
    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")
    parameter: PyList[ParameterDefinition] | None = Field(
        None, alias="parameter", serialization_alias="parameter"
    )
    publisher: str | None = Field(
        None, alias="publisher", serialization_alias="publisher"
    )
    purpose: str | None = Field(None, alias="purpose", serialization_alias="purpose")
    related_artifact: PyList[RelatedArtifact] | None = Field(
        None, alias="relatedArtifact", serialization_alias="relatedArtifact"
    )
    reviewer: PyList[ContactDetail] | None = Field(
        None, alias="reviewer", serialization_alias="reviewer"
    )
    status: Literal["draft", "active", "retired", "unknown"] = Field(
        alias="status", serialization_alias="status"
    )
    subject_codeable_concept: CodeableConcept | None = Field(
        None,
        alias="subjectCodeableConcept",
        serialization_alias="subjectCodeableConcept",
    )
    subject_reference: Reference | None = Field(
        None, alias="subjectReference", serialization_alias="subjectReference"
    )
    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: CodeableConcept = Field(alias="type", serialization_alias="type")
    url: str | None = Field(None, alias="url", serialization_alias="url")
    usage: str | None = Field(None, alias="usage", serialization_alias="usage")
    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) -> Library:
        return cls.model_validate_json(json)
