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


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

    all_day: bool | None = Field(None, alias="allDay", serialization_alias="allDay")
    available_end_time: str | None = Field(
        None, alias="availableEndTime", serialization_alias="availableEndTime"
    )
    available_start_time: str | None = Field(
        None, alias="availableStartTime", serialization_alias="availableStartTime"
    )
    days_of_week: (
        PyList[Literal["mon", "tue", "wed", "thu", "fri", "sat", "sun"]] | None
    ) = Field(None, alias="daysOfWeek", serialization_alias="daysOfWeek")


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

    code: CodeableConcept | None = Field(None, alias="code", serialization_alias="code")
    comment: str | None = Field(None, alias="comment", serialization_alias="comment")


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

    description: str = Field(alias="description", serialization_alias="description")
    during: Period | None = Field(None, alias="during", serialization_alias="during")


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

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

    active: bool | None = Field(None, alias="active", serialization_alias="active")
    appointment_required: bool | None = Field(
        None, alias="appointmentRequired", serialization_alias="appointmentRequired"
    )
    availability_exceptions: str | None = Field(
        None,
        alias="availabilityExceptions",
        serialization_alias="availabilityExceptions",
    )
    available_time: PyList[HealthcareServiceAvailableTime] | None = Field(
        None, alias="availableTime", serialization_alias="availableTime"
    )
    category: PyList[CodeableConcept] | None = Field(
        None, alias="category", serialization_alias="category"
    )
    characteristic: PyList[CodeableConcept] | None = Field(
        None, alias="characteristic", serialization_alias="characteristic"
    )
    comment: str | None = Field(None, alias="comment", serialization_alias="comment")
    communication: PyList[CodeableConcept] | None = Field(
        None, alias="communication", serialization_alias="communication"
    )
    coverage_area: PyList[Reference] | None = Field(
        None, alias="coverageArea", serialization_alias="coverageArea"
    )
    eligibility: PyList[HealthcareServiceEligibility] | None = Field(
        None, alias="eligibility", serialization_alias="eligibility"
    )
    endpoint: PyList[Reference] | None = Field(
        None, alias="endpoint", serialization_alias="endpoint"
    )
    extra_details: str | None = Field(
        None, alias="extraDetails", serialization_alias="extraDetails"
    )
    identifier: PyList[Identifier] | None = Field(
        None, alias="identifier", serialization_alias="identifier"
    )
    location: PyList[Reference] | None = Field(
        None, alias="location", serialization_alias="location"
    )
    name: str | None = Field(None, alias="name", serialization_alias="name")
    not_available: PyList[HealthcareServiceNotAvailable] | None = Field(
        None, alias="notAvailable", serialization_alias="notAvailable"
    )
    photo: Attachment | None = Field(None, alias="photo", serialization_alias="photo")
    program: PyList[CodeableConcept] | None = Field(
        None, alias="program", serialization_alias="program"
    )
    provided_by: Reference | None = Field(
        None, alias="providedBy", serialization_alias="providedBy"
    )
    referral_method: PyList[CodeableConcept] | None = Field(
        None, alias="referralMethod", serialization_alias="referralMethod"
    )
    service_provision_code: PyList[CodeableConcept] | None = Field(
        None, alias="serviceProvisionCode", serialization_alias="serviceProvisionCode"
    )
    specialty: PyList[CodeableConcept] | None = Field(
        None, alias="specialty", serialization_alias="specialty"
    )
    telecom: PyList[ContactPoint] | None = Field(
        None, alias="telecom", serialization_alias="telecom"
    )
    type: PyList[CodeableConcept] | None = Field(
        None, alias="type", serialization_alias="type"
    )

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