# This file is automatically generated by generate_pydantic_model_defs.py.
# It needs to be copied to gen_epix/omopdb/domain/model/omop.py.
# The order of certain code elements may need to be changed manually.

from __future__ import annotations

from datetime import date, datetime
from typing import Any, ClassVar
from uuid import UUID

from pydantic import Field, RootModel

from gen_epix.fastapp.domain import Entity, create_keys
from gen_epix.omopdb.domain import DOMAIN, enum
from gen_epix.omopdb.domain.model.base import Model

_SERVICE_TYPE = enum.ServiceType.OMOP
_ENTITY_KWARGS = {
    "service_type": _SERVICE_TYPE,
    "schema_name": _SERVICE_TYPE.value.lower(),
}


class ModelModel(RootModel[Any]):
    root: Any


class Person(Model):

    ENTITY: ClassVar = Entity(
        snake_case_plural_name="Persons",
        table_name="person",
        persistable=True,
        keys=create_keys({1: "person_id"}),
        **_ENTITY_KWARGS,
    )

    care_site_id: UUID | None = Field(
        None, description="care_site_id", title="Care Site Id"
    )
    day_of_birth: int | None = Field(
        None, description="day_of_birth", ge=1, le=31, title="Day Of Birth"
    )
    ethnicity_concept_id: int | None = Field(
        None,
        description="ethnicity_concept_id",
        le=2147483647,
        title="Ethnicity Concept Id",
    )
    ethnicity_source_concept_id: int | None = Field(
        None,
        description="ethnicity_source_concept_id",
        le=2147483647,
        title="Ethnicity Source Concept Id",
    )
    ethnicity_source_value: str | None = Field(
        None,
        description="ethnicity_source_value",
        max_length=50,
        title="Ethnicity Source Value",
    )
    birth_datetime: datetime | None = Field(
        None, description="birth_datetime", title="Birth Datetime"
    )
    death_datetime: datetime | None = Field(
        None, description="death_datetime", title="Death Datetime"
    )
    gender_concept_id: int | None = Field(
        None, description="gender_concept_id", le=2147483647, title="Gender Concept Id"
    )
    gender_source_concept_id: int | None = Field(
        None,
        description="gender_source_concept_id",
        le=2147483647,
        title="Gender Source Concept Id",
    )
    gender_source_value: str | None = Field(
        None,
        description="gender_source_value",
        max_length=50,
        title="Gender Source Value",
    )
    location_id: UUID | None = Field(
        None, description="location_id", title="Location Id"
    )
    month_of_birth: int | None = Field(
        None, description="month_of_birth", ge=1, le=12, title="Month Of Birth"
    )
    person_id: UUID = Field(
        ..., description="person_id, PRIMARY KEY", title="Person Id"
    )
    person_source_value: str | None = Field(
        None,
        description="person_source_value",
        max_length=50,
        title="Person Source Value",
    )
    person_type_concept_id: int = Field(
        ...,
        description="person_type_concept_id",
        le=2147483647,
        title="Person Type Concept Id",
    )
    provider_id: UUID | None = Field(
        None, description="provider_id", title="Provider Id"
    )
    race_concept_id: int | None = Field(
        None, description="race_concept_id", le=2147483647, title="Race Concept Id"
    )
    race_source_concept_id: int | None = Field(
        None,
        description="race_source_concept_id",
        le=2147483647,
        title="Race Source Concept Id",
    )
    race_source_value: str | None = Field(
        None, description="race_source_value", max_length=50, title="Race Source Value"
    )
    year_of_birth: int | None = Field(
        None, description="year_of_birth", title="Year Of Birth"
    )
    provenance_id: UUID = Field(
        ..., description="provenance_id", title="Provenance Id"
    )  # should be for every omop_subject unique
    source_traceback: str = Field(
        ..., description="source_traceback", title="Source Traceback"
    )


class ObservationPeriod(Model):

    ENTITY: ClassVar = Entity(
        snake_case_plural_name="ObservationPeriods",
        table_name="observation_period",
        persistable=True,
        keys=create_keys({1: "observation_period_id"}),
        **_ENTITY_KWARGS,
    )

    period_type_concept_id: int = Field(
        ...,
        description="period_type_concept_id",
        le=2147483647,
        title="Period Type Concept Id",
    )
    observation_period_end_date: date | None = Field(
        None,
        description="observation_period_end_date",
        title="Observation Period End Date",
    )
    observation_period_end_iso_interval: str = Field(
        ...,
        description="observation_period_end_iso_interval",
        max_length=55,
        title="Observation Period End Iso Interval",
    )
    observation_period_id: UUID = Field(
        ...,
        description="observation_period_id, PRIMARY KEY",
        title="Observation Period Id",
    )
    observation_period_start_date: date | None = Field(
        None,
        description="observation_period_start_date",
        title="Observation Period Start Date",
    )
    observation_period_start_iso_interval: str = Field(
        ...,
        description="observation_period_start_iso_interval",
        max_length=55,
        title="Observation Period Start Iso Interval",
    )
    person_id: UUID = Field(..., description="person_id", title="Person Id")


class VisitOccurrence(Model):

    ENTITY: ClassVar = Entity(
        snake_case_plural_name="VisitOccurrences",
        table_name="visit_occurrence",
        persistable=True,
        keys=create_keys({1: "visit_occurrence_id"}),
        **_ENTITY_KWARGS,
    )

    admitted_from_concept_id: int = Field(
        ...,
        description="admitted_from_concept_id",
        le=2147483647,
        title="Admitted From Concept Id",
    )
    discharge_to_concept_id: int = Field(
        ...,
        description="discharge_to_concept_id",
        le=2147483647,
        title="Discharge To Concept Id",
    )
    visit_concept_id: int = Field(
        ..., description="visit_concept_id", le=2147483647, title="Visit Concept Id"
    )
    visit_source_concept_id: int = Field(
        ...,
        description="visit_source_concept_id",
        le=2147483647,
        title="Visit Source Concept Id",
    )
    visit_type_concept_id: int = Field(
        ...,
        description="visit_type_concept_id",
        le=2147483647,
        title="Visit Type Concept Id",
    )
    care_site_id: UUID | None = Field(
        None, description="care_site_id", title="Care Site Id"
    )
    person_id: UUID = Field(..., description="person_id", title="Person Id")
    preceding_visit_occurrence_id: UUID | None = Field(
        None,
        description="preceding_visit_occurrence_id",
        title="Preceding Visit Occurrence Id",
    )
    provider_id: UUID | None = Field(
        None, description="provider_id", title="Provider Id"
    )
    visit_occurrence_id: UUID = Field(
        ..., description="visit_occurrence_id, PRIMARY KEY", title="Visit Occurrence Id"
    )
    visit_end_date: date | None = Field(
        None, description="visit_end_date", title="Visit End Date"
    )
    visit_end_datetime: datetime = Field(
        ..., description="visit_end_datetime", title="Visit End Datetime"
    )
    visit_start_date: date | None = Field(
        None, description="visit_start_date", title="Visit Start Date"
    )
    visit_start_datetime: datetime = Field(
        ..., description="visit_start_datetime", title="Visit Start Datetime"
    )
    visit_source_value: str | None = Field(
        None,
        description="visit_source_value",
        max_length=50,
        title="Visit Source Value",
    )
    admitted_from_source_value: str | None = Field(
        None,
        description="admitted_from_source_value",
        max_length=50,
        title="Admitted From Source Value",
    )
    discharge_to_source_value: str | None = Field(
        None,
        description="discharge_to_source_value",
        max_length=50,
        title="Discharge To Source Value",
    )
    provenance_id: UUID = Field(..., description="provenance_id", title="Provenance Id")
    source_traceback: str = Field(
        ..., description="source_traceback", title="Source Traceback"
    )


class VisitDetail(Model):

    ENTITY: ClassVar = Entity(
        snake_case_plural_name="VisitDetails",
        table_name="visit_detail",
        persistable=True,
        keys=create_keys({1: "visit_detail_id"}),
        **_ENTITY_KWARGS,
    )

    admitted_from_source_value: int = Field(
        ...,
        description="admitted_from_source_value",
        le=2147483647,
        title="Admitted From Source Value",
    )
    discharge_to_concept_id: int = Field(
        ...,
        description="discharge_to_concept_id",
        le=2147483647,
        title="Discharge To Concept Id",
    )
    visit_detail_concept_id: int = Field(
        ...,
        description="visit_detail_concept_id",
        le=2147483647,
        title="Visit Detail Concept Id",
    )
    visit_detail_source_concept_id: int = Field(
        ...,
        description="visit_detail_source_concept_id",
        le=2147483647,
        title="Visit Detail Source Concept Id",
    )
    visit_detail_type_concept_id: int = Field(
        ...,
        description="visit_detail_type_concept_id",
        le=2147483647,
        title="Visit Detail Type Concept Id",
    )
    care_site_id: UUID | None = Field(
        None, description="care_site_id", title="Care Site Id"
    )
    person_id: UUID = Field(..., description="person_id", title="Person Id")
    preceding_visit_detail_id: UUID | None = Field(
        None, description="preceding_visit_detail_id", title="Preceding Visit Detail Id"
    )
    provider_id: UUID | None = Field(
        None, description="provider_id", title="Provider Id"
    )
    visit_detail_id: UUID = Field(
        ..., description="visit_detail_id, PRIMARY KEY", title="Visit Detail Id"
    )
    visit_detail_end_date: date = Field(
        ..., description="visit_detail_end_date", title="Visit Detail End Date"
    )
    visit_detail_end_datetime: datetime | None = Field(
        None, description="visit_detail_end_datetime", title="Visit Detail End Datetime"
    )
    visit_detail_start_date: date = Field(
        ..., description="visit_detail_start_date", title="Visit Detail Start Date"
    )
    visit_detail_start_datetime: datetime | None = Field(
        None,
        description="visit_detail_start_datetime",
        title="Visit Detail Start Datetime",
    )
    visit_detail_parent_id: UUID | None = Field(
        None, description="visit_detail_parent_id", title="Visit Detail Parent Id"
    )
    visit_detail_source_value: str | None = Field(
        None,
        description="visit_detail_source_value",
        max_length=50,
        title="Visit Detail Source Value",
    )
    admitted_from_concept_id: str | None = Field(
        None,
        description="admitted_from_concept_id",
        max_length=50,
        title="Admitted From Concept Id",
    )
    discharge_to_source_value: str | None = Field(
        None,
        description="discharge_to_source_value",
        max_length=50,
        title="Discharge To Source Value",
    )
    visit_occurrence_id: UUID = Field(
        ..., description="visit_occurrence_id", title="Visit Occurrence Id"
    )
    provenance_id: UUID = Field(..., description="provenance_id", title="Provenance Id")
    source_traceback: str = Field(
        ..., description="source_traceback", title="Source Traceback"
    )


class ConditionOccurrence(Model):

    ENTITY: ClassVar = Entity(
        snake_case_plural_name="ConditionOccurrences",
        table_name="condition_occurrence",
        persistable=True,
        keys=create_keys({1: "condition_occurrence_id"}),
        **_ENTITY_KWARGS,
    )

    condition_concept_id: int = Field(
        ...,
        description="condition_concept_id",
        le=2147483647,
        title="Condition Concept Id",
    )
    condition_end_date: date | None = Field(
        None, description="condition_end_date", title="Condition End Date"
    )
    condition_source_concept_id: int = Field(
        ...,
        description="condition_source_concept_id",
        le=2147483647,
        title="Condition Source Concept Id",
    )
    condition_occurrence_id: UUID = Field(
        ...,
        description="condition_occurrence_id, PRIMARY KEY",
        title="Condition Occurrence Id",
    )
    condition_status_concept_id: int = Field(
        ...,
        description="condition_status_concept_id",
        le=2147483647,
        title="Condition Status Concept Id",
    )
    condition_type_concept_id: int = Field(
        ...,
        description="condition_type_concept_id",
        le=2147483647,
        title="Condition Type Concept Id",
    )
    condition_end_datetime: datetime | None = Field(
        None, description="condition_end_datetime", title="Condition End Datetime"
    )
    condition_end_iso_interval: str | None = Field(
        None,
        description="condition_end_iso_interval",
        max_length=55,
        title="Condition End Iso Interval",
    )
    condition_start_date: date = Field(
        ..., description="condition_start_date", title="Condition Start Date"
    )
    condition_start_datetime: datetime = Field(
        ..., description="condition_start_datetime", title="Condition Start Datetime"
    )
    condition_start_iso_interval: str = Field(
        ...,
        description="condition_start_iso_interval",
        max_length=55,
        title="Condition Start Iso Interval",
    )
    stop_reason: str | None = Field(
        None, description="stop_reason", max_length=20, title="Stop Reason"
    )
    condition_source_value: str | None = Field(
        None,
        description="condition_source_value",
        max_length=50,
        title="Condition Source Value",
    )
    condition_status_source_value: str | None = Field(
        None,
        description="condition_status_source_value",
        max_length=50,
        title="Condition Status Source Value",
    )
    person_id: UUID = Field(..., description="person_id", title="Person Id")
    provider_id: UUID | None = Field(
        None, description="provider_id", title="Provider Id"
    )
    visit_detail_id: UUID | None = Field(
        None, description="visit_detail_id", title="Visit Detail Id"
    )
    visit_occurrence_id: UUID | None = Field(
        None, description="visit_occurrence_id", title="Visit Occurrence Id"
    )
    provenance_id: UUID = Field(..., description="provenance_id", title="Provenance Id")
    source_traceback: str = Field(
        ..., description="source_traceback", title="Source Traceback"
    )


class DrugExposure(Model):

    ENTITY: ClassVar = Entity(
        snake_case_plural_name="DrugExposures",
        table_name="drug_exposure",
        persistable=True,
        keys=create_keys({1: "drug_exposure_id"}),
        **_ENTITY_KWARGS,
    )

    drug_concept_id: int = Field(
        ..., description="drug_concept_id", le=2147483647, title="Drug Concept Id"
    )
    drug_source_concept_id: int = Field(
        ...,
        description="drug_source_concept_id",
        le=2147483647,
        title="Drug Source Concept Id",
    )
    drug_type_concept_id: int = Field(
        ...,
        description="drug_type_concept_id",
        le=2147483647,
        title="Drug Type Concept Id",
    )
    drug_exposure_end_date: date | None = Field(
        None, description="drug_exposure_end_date", title="Drug Exposure End Date"
    )
    drug_exposure_id: UUID = Field(
        ..., description="drug_exposure_id, PRIMARY KEY", title="Drug Exposure Id"
    )
    drug_exposure_end_datetime: datetime | None = Field(
        None,
        description="drug_exposure_end_datetime",
        title="Drug Exposure End Datetime",
    )
    drug_exposure_end_iso_interval: str | None = Field(
        None,
        description="drug_exposure_end_iso_interval",
        max_length=55,
        title="Drug Exposure End Iso Interval",
    )
    drug_exposure_start_date: date | None = Field(
        None, description="drug_exposure_start_date", title="Drug Exposure Start Date"
    )
    drug_exposure_start_datetime: datetime | None = Field(
        None,
        description="drug_exposure_start_datetime",
        title="Drug Exposure Start Datetime",
    )
    drug_exposure_start_iso_interval: str = Field(
        ...,
        description="drug_exposure_start_iso_interval",
        max_length=55,
        title="Drug Exposure Start Iso Interval",
    )
    verbatim_end_date: date | None = Field(
        None, description="verbatim_end_date", title="Verbatim End Date"
    )
    quantity: float | None = Field(None, description="quantity", title="Quantity")
    refills: int | None = Field(None, description="refills", title="Refills")
    days_supply: int | None = Field(
        None, description="days_supply", title="Days Supply"
    )
    stop_reason: str | None = Field(
        None, description="stop_reason", max_length=20, title="Stop Reason"
    )
    lot_number: str | None = Field(
        None, description="lot_number", max_length=50, title="Lot Number"
    )
    drug_source_value: str | None = Field(
        None, description="drug_source_value", max_length=50, title="Drug Source Value"
    )
    route_source_value: str | None = Field(
        None,
        description="route_source_value",
        max_length=50,
        title="Route Source Value",
    )
    dose_unit_source_value: str | None = Field(
        None,
        description="dose_unit_source_value",
        max_length=50,
        title="Dose Unit Source Value",
    )
    sig: str | None = Field(None, description="sig", title="Sig")
    route_concept_id: int | None = Field(
        None, description="route_concept_id", le=2147483647, title="Route Concept Id"
    )
    person_id: UUID = Field(..., description="person_id", title="Person Id")
    provider_id: UUID | None = Field(
        None, description="provider_id", title="Provider Id"
    )
    visit_detail_id: UUID | None = Field(
        None, description="visit_detail_id", title="Visit Detail Id"
    )
    visit_occurrence_id: UUID | None = Field(
        None, description="visit_occurrence_id", title="Visit Occurrence Id"
    )
    provenance_id: UUID = Field(..., description="provenance_id", title="Provenance Id")
    source_traceback: str = Field(
        ..., description="source_traceback", title="Source Traceback"
    )


class ProcedureOccurrence(Model):

    ENTITY: ClassVar = Entity(
        snake_case_plural_name="ProcedureOccurrences",
        table_name="procedure_occurrence",
        persistable=True,
        keys=create_keys({1: "procedure_occurrence_id"}),
        **_ENTITY_KWARGS,
    )

    modifier_concept_id: int | None = Field(
        None,
        description="modifier_concept_id",
        le=2147483647,
        title="Modifier Concept Id",
    )
    procedure_concept_id: int = Field(
        ...,
        description="procedure_concept_id",
        le=2147483647,
        title="Procedure Concept Id",
    )
    procedure_type_concept_id: int = Field(
        ...,
        description="procedure_type_concept_id",
        le=2147483647,
        title="Procedure Type Concept Id",
    )
    procedure_occurrence_id: UUID = Field(
        ...,
        description="procedure_occurrence_id, PRIMARY KEY",
        title="Procedure Occurrence Id",
    )
    provider_id: int | None = Field(
        None, description="provider_id", title="Provider Id"
    )
    visit_occurrence_id: int | None = Field(
        None, description="visit_occurrence_id", title="Visit Occurrence Id"
    )
    visit_detail_id: int | None = Field(
        None, description="visit_detail_id", title="Visit Detail Id"
    )
    procedure_date: date | None = Field(
        None, description="procedure_date", title="Procedure Date"
    )
    procedure_datetime: datetime | None = Field(
        None, description="procedure_datetime", title="Procedure Datetime"
    )
    quantity: int | None = Field(None, description="quantity", title="Quantity")
    procedure_source_concept_id: int = Field(
        ...,
        description="procedure_source_concept_id",
        le=2147483647,
        title="Procedure Source Concept Id",
    )
    procedure_source_value: str | None = Field(
        None,
        description="procedure_source_value",
        max_length=50,
        title="Procedure Source Value",
    )
    modifier_source_value: str | None = Field(
        None,
        description="modifier_source_value",
        max_length=50,
        title="Modifier Source Value",
    )
    procedure_iso_interval: str = Field(
        ...,
        description="procedure_iso_interval",
        max_length=55,
        title="Procedure Iso Interval",
    )
    person_id: UUID = Field(..., description="person_id", title="Person Id")
    provenance_id: UUID = Field(..., description="provenance_id", title="Provenance Id")
    source_traceback: str = Field(
        ..., description="source_traceback", title="Source Traceback"
    )


class DeviceExposure(Model):

    ENTITY: ClassVar = Entity(
        snake_case_plural_name="DeviceExposures",
        table_name="device_exposure",
        persistable=True,
        keys=create_keys({1: "device_exposure_id"}),
        **_ENTITY_KWARGS,
    )

    device_concept_id: int = Field(
        ..., description="device_concept_id", le=2147483647, title="Device Concept Id"
    )
    device_source_concept_id: int = Field(
        ...,
        description="device_source_concept_id",
        le=2147483647,
        title="Device Source Concept Id",
    )
    device_type_concept_id: int = Field(
        ...,
        description="device_type_concept_id",
        le=2147483647,
        title="Device Type Concept Id",
    )
    device_exposure_end_date: date | None = Field(
        None, description="device_exposure_end_date", title="Device Exposure End Date"
    )
    device_exposure_id: UUID = Field(
        ..., description="device_exposure_id, PRIMARY KEY", title="Device Exposure Id"
    )
    device_exposure_end_datetime: datetime | None = Field(
        None,
        description="device_exposure_end_datetime",
        title="Device Exposure End Datetime",
    )
    device_exposure_end_iso_interval: str | None = Field(
        None,
        description="device_exposure_end_iso_interval",
        max_length=55,
        title="Device Exposure End Iso Interval",
    )
    device_exposure_start_date: date = Field(
        ...,
        description="device_exposure_start_date",
        title="Device Exposure Start Date",
    )
    device_exposure_start_datetime: datetime = Field(
        ...,
        description="device_exposure_start_datetime",
        title="Device Exposure Start Datetime",
    )
    device_exposure_start_iso_interval: str = Field(
        ...,
        description="device_exposure_start_iso_interval",
        max_length=55,
        title="Device Exposure Start Iso Interval",
    )
    quantity: int | None = Field(None, description="quantity", title="Quantity")
    unique_device_id: str | None = Field(
        None, description="unique_device_id", max_length=50, title="Unique Device Id"
    )
    device_source_value: str | None = Field(
        None,
        description="device_source_value",
        max_length=50,
        title="Device Source Value",
    )
    person_id: UUID = Field(..., description="person_id", title="Person Id")
    provider_id: UUID | None = Field(
        None, description="provider_id", title="Provider Id"
    )
    visit_detail_id: UUID | None = Field(
        None, description="visit_detail_id", title="Visit Detail Id"
    )
    visit_occurrence_id: UUID | None = Field(
        None, description="visit_occurrence_id", title="Visit Occurrence Id"
    )
    provenance_id: UUID = Field(..., description="provenance_id", title="Provenance Id")
    source_traceback: str = Field(
        ..., description="source_traceback", title="Source Traceback"
    )


class Measurement(Model):

    ENTITY: ClassVar = Entity(
        snake_case_plural_name="Measurements",
        table_name="measurement",
        persistable=True,
        keys=create_keys({1: "measurement_id"}),
        **_ENTITY_KWARGS,
    )

    measurement_concept_id: int = Field(
        ...,
        description="measurement_concept_id",
        le=2147483647,
        title="Measurement Concept Id",
    )
    measurement_source_concept_id: int = Field(
        ...,
        description="measurement_source_concept_id",
        le=2147483647,
        title="Measurement Source Concept Id",
    )
    measurement_type_concept_id: int = Field(
        ...,
        description="measurement_type_concept_id",
        le=2147483647,
        title="Measurement Type Concept Id",
    )
    measurement_date: date = Field(
        ..., description="measurement_date", title="Measurement Date"
    )
    measurement_iso_interval: str = Field(
        ...,
        description="measurement_iso_interval",
        max_length=55,
        title="Measurement Iso Interval",
    )
    measurement_id: UUID = Field(
        ..., description="measurement_id, PRIMARY KEY", title="Measurement Id"
    )
    measurement_datetime: datetime | None = Field(
        None, description="measurement_datetime", title="Measurement Datetime"
    )
    value_as_number: float | None = Field(
        None, description="value_as_number", title="Value As Number"
    )
    range_low: float | None = Field(None, description="range_low", title="Range Low")
    range_high: float | None = Field(None, description="range_high", title="Range High")
    operator_concept_id: int | None = Field(
        None,
        description="operator_concept_id",
        le=2147483647,
        title="Operator Concept Id",
    )
    measurement_time: str | None = Field(
        None, description="measurement_time", max_length=10, title="Measurement Time"
    )
    measurement_source_value: str | None = Field(
        None,
        description="measurement_source_value",
        max_length=50,
        title="Measurement Source Value",
    )
    unit_source_value: str | None = Field(
        None, description="unit_source_value", max_length=50, title="Unit Source Value"
    )
    value_source_value: str | None = Field(
        None,
        description="value_source_value",
        max_length=50,
        title="Value Source Value",
    )
    unit_concept_id: int | None = Field(
        None, description="unit_concept_id", le=2147483647, title="Unit Concept Id"
    )
    value_as_concept_id: int | None = Field(
        None,
        description="value_as_concept_id",
        le=2147483647,
        title="Value As Concept Id",
    )
    person_id: UUID = Field(..., description="person_id", title="Person Id")
    provider_id: UUID | None = Field(
        None, description="provider_id", title="Provider Id"
    )
    visit_detail_id: UUID | None = Field(
        None, description="visit_detail_id", title="Visit Detail Id"
    )
    visit_occurrence_id: UUID | None = Field(
        None, description="visit_occurrence_id", title="Visit Occurrence Id"
    )
    provided_by_organization_id: UUID | None = Field(
        None,
        description="provided_by_organization_id",
        title="Provided By Organization Id",
    )
    measurement_derived_from_specimen_id: UUID | None = Field(
        None,
        description="measurement_derived_from_specimen_id",
        title="Measurement Derived From Specimen Id",
    )
    measurement_derived_from_measurement_id: UUID | None = Field(
        None,
        description="measurement_derived_from_measurement_id",
        title="Measurement Derived From Measurement Id",
    )
    source_traceback: str = Field(
        ..., description="source_traceback", title="Source Traceback"
    )
    provenance_id: UUID = Field(..., description="provenance_id", title="Provenance Id")


class Observation(Model):

    ENTITY: ClassVar = Entity(
        snake_case_plural_name="Observations",
        table_name="observation",
        persistable=True,
        keys=create_keys({1: "observation_id"}),
        **_ENTITY_KWARGS,
    )

    obs_event_field_concept_id: int | None = Field(
        None,
        description="obs_event_field_concept_id",
        le=2147483647,
        title="Obs Event Field Concept Id",
    )
    observation_concept_id: int = Field(
        ...,
        description="observation_concept_id",
        le=2147483647,
        title="Observation Concept Id",
    )
    observation_source_concept_id: int = Field(
        ...,
        description="observation_source_concept_id",
        le=2147483647,
        title="Observation Source Concept Id",
    )
    observation_type_concept_id: int = Field(
        ...,
        description="observation_type_concept_id",
        le=2147483647,
        title="Observation Type Concept Id",
    )
    qualifier_concept_id: int | None = Field(
        None,
        description="qualifier_concept_id",
        le=2147483647,
        title="Qualifier Concept Id",
    )
    observation_date: date | None = Field(
        None, description="observation_date", title="Observation Date"
    )
    observation_datetime: datetime | None = Field(
        None, description="observation_datetime", title="Observation Datetime"
    )
    observation_id: UUID = Field(
        ..., description="observation_id, PRIMARY KEY", title="Observation Id"
    )
    observation_event_id: int | None = Field(
        None, description="observation_event_id", title="Observation Event Id"
    )
    observation_iso_interval: str = Field(
        ...,
        description="observation_iso_interval",
        max_length=55,
        title="Observation Iso Interval",
    )
    value_as_datetime: datetime | None = Field(
        None, description="value_as_datetime", title="Value As Datetime"
    )
    value_as_iso_interval: str | None = Field(
        None,
        description="value_as_iso_interval",
        max_length=55,
        title="Value As Iso Interval",
    )
    value_as_number: float | None = Field(
        None, description="value_as_number", title="Value As Number"
    )
    observation_source_value: str | None = Field(
        None,
        description="observation_source_value",
        max_length=50,
        title="Observation Source Value",
    )
    unit_source_value: str | None = Field(
        None, description="unit_source_value", max_length=50, title="Unit Source Value"
    )
    qualifier_source_value: str | None = Field(
        None,
        description="qualifier_source_value",
        max_length=50,
        title="Qualifier Source Value",
    )
    value_as_string: str | None = Field(
        None, description="value_as_string", max_length=60, title="Value As String"
    )
    unit_concept_id: int | None = Field(
        None, description="unit_concept_id", le=2147483647, title="Unit Concept Id"
    )
    value_as_concept_id: int | None = Field(
        None,
        description="value_as_concept_id",
        le=2147483647,
        title="Value As Concept Id",
    )
    person_id: UUID = Field(..., description="person_id", title="Person Id")
    provider_id: UUID | None = Field(
        None, description="provider_id", title="Provider Id"
    )
    visit_detail_id: UUID | None = Field(
        None, description="visit_detail_id", title="Visit Detail Id"
    )
    visit_occurrence_id: UUID | None = Field(
        None, description="visit_occurrence_id", title="Visit Occurrence Id"
    )
    provenance_id: UUID = Field(..., description="provenance_id", title="Provenance Id")
    source_traceback: str = Field(
        ..., description="source_traceback", title="Source Traceback"
    )


class Note(Model):

    ENTITY: ClassVar = Entity(
        snake_case_plural_name="Notes",
        table_name="note",
        persistable=True,
        keys=create_keys({}),
        **_ENTITY_KWARGS,
    )

    encoding_concept_id: int = Field(
        ...,
        description="encoding_concept_id",
        le=2147483647,
        title="Encoding Concept Id",
    )
    language_concept_id: int = Field(
        ...,
        description="language_concept_id",
        le=2147483647,
        title="Language Concept Id",
    )
    note_class_concept_id: int = Field(
        ...,
        description="note_class_concept_id",
        le=2147483647,
        title="Note Class Concept Id",
    )
    note_event_field_concept_id: int | None = Field(
        None,
        description="note_event_field_concept_id",
        le=2147483647,
        title="Note Event Field Concept Id",
    )
    note_type_concept_id: int = Field(
        ...,
        description="note_type_concept_id",
        le=2147483647,
        title="Note Type Concept Id",
    )
    note_date: date = Field(..., description="note_date", title="Note Date")
    note_datetime: datetime | None = Field(
        None, description="note_datetime", title="Note Datetime"
    )
    note_event_id: int | None = Field(
        None, description="note_event_id", title="Note Event Id"
    )
    note_id: UUID = Field(..., description="note_id, PRIMARY KEY", title="Note Id")
    note_title: str | None = Field(
        None, description="note_title", max_length=250, title="Note Title"
    )
    note_source_value: str | None = Field(
        None, description="note_source_value", max_length=50, title="Note Source Value"
    )
    note_text: str = Field(..., description="note_text", title="Note Text")
    person_id: UUID = Field(..., description="person_id", title="Person Id")
    provider_id: UUID | None = Field(
        None, description="provider_id", title="Provider Id"
    )
    visit_detail_id: UUID | None = Field(
        None, description="visit_detail_id", title="Visit Detail Id"
    )
    visit_occurrence_id: UUID | None = Field(
        None, description="visit_occurrence_id", title="Visit Occurrence Id"
    )
    provenance_id: UUID = Field(..., description="provenance_id", title="Provenance Id")
    source_traceback: str = Field(
        ..., description="source_traceback", title="Source Traceback"
    )


class NoteNlp(Model):

    ENTITY: ClassVar = Entity(
        snake_case_plural_name="NoteNlps",
        table_name="note_nlp",
        persistable=True,
        keys=create_keys({}),
        **_ENTITY_KWARGS,
    )

    note_nlp_concept_id: int | None = Field(
        None,
        description="note_nlp_concept_id",
        le=2147483647,
        title="Note Nlp Concept Id",
    )
    note_nlp_source_concept_id: int | None = Field(
        None,
        description="note_nlp_source_concept_id",
        le=2147483647,
        title="Note Nlp Source Concept Id",
    )
    nlp_date: date = Field(..., description="nlp_date", title="Nlp Date")
    nlp_datetime: datetime | None = Field(
        None, description="nlp_datetime", title="Nlp Datetime"
    )
    note_nlp_id: UUID = Field(
        ..., description="note_nlp_id, PRIMARY KEY", title="Note Nlp Id"
    )
    note_id: UUID = Field(..., description="note_id", title="Note Id")
    section_concept_id: int | None = Field(
        None,
        description="section_concept_id",
        le=2147483647,
        title="Section Concept Id",
    )
    term_exists: str | None = Field(
        None, description="term_exists", max_length=1, title="Term Exists"
    )
    term_modifiers: str | None = Field(
        None, description="term_modifiers", max_length=2000, title="Term Modifiers"
    )
    snippet: str | None = Field(
        None, description="snippet", max_length=250, title="Snippet"
    )
    lexical_variant: str = Field(
        ..., description="lexical_variant", max_length=250, title="Lexical Variant"
    )
    nlp_system: str | None = Field(
        None, description="nlp_system", max_length=250, title="Nlp System"
    )
    offset: str | None = Field(
        None, description="offset", max_length=50, title="Offset"
    )
    term_temporal: str | None = Field(
        None, description="term_temporal", max_length=50, title="Term Temporal"
    )


class Specimen(Model):

    ENTITY: ClassVar = Entity(
        snake_case_plural_name="Specimens",
        table_name="specimen",
        persistable=True,
        keys=create_keys({1: "specimen_id"}),
        **_ENTITY_KWARGS,
    )

    anatomic_site_concept_id: int | None = Field(
        None,
        description="anatomic_site_concept_id",
        le=2147483647,
        title="Anatomic Site Concept Id",
    )
    disease_status_concept_id: int | None = Field(
        None,
        description="disease_status_concept_id",
        le=2147483647,
        title="Disease Status Concept Id",
    )
    specimen_concept_id: int = Field(
        ...,
        description="specimen_concept_id",
        le=2147483647,
        title="Specimen Concept Id",
    )
    specimen_type_concept_id: int = Field(
        ...,
        description="specimen_type_concept_id",
        le=2147483647,
        title="Specimen Type Concept Id",
    )
    unit_concept_id: int | None = Field(
        None, description="unit_concept_id", le=2147483647, title="Unit Concept Id"
    )
    specimen_id: UUID = Field(
        ..., description="specimen_id, PRIMARY KEY", title="Specimen Id"
    )
    specimen_date: date | None = Field(
        None, description="specimen_date", title="Specimen Date"
    )
    specimen_datetime: datetime | None = Field(
        None, description="specimen_datetime", title="Specimen Datetime"
    )
    quantity: float | None = Field(None, description="quantity", title="Quantity")
    person_id: UUID = Field(..., description="person_id", title="Person Id")
    specimen_source_id: str | None = Field(
        None,
        description="specimen_source_id",
        max_length=50,
        title="Specimen Source Id",
    )
    specimen_source_value: str | None = Field(
        None,
        description="specimen_source_value",
        max_length=50,
        title="Specimen Source Value",
    )
    unit_source_value: str | None = Field(
        None, description="unit_source_value", max_length=50, title="Unit Source Value"
    )
    anatomic_site_source_value: str | None = Field(
        None,
        description="anatomic_site_source_value",
        max_length=50,
        title="Anatomic Site Source Value",
    )
    disease_status_source_value: str | None = Field(
        None,
        description="disease_status_source_value",
        max_length=50,
        title="Disease Status Source Value",
    )
    specimen_iso_interval: str = Field(
        ...,
        description="specimen_iso_interval",
        max_length=55,
        title="Specimen Iso Interval",
    )
    visit_occurrence_id: UUID | None = Field(
        None, description="visit_occurrence_id", title="Visit Occurrence Id"
    )
    derived_from_specimen_id: UUID | None = Field(
        None, description="derived_from_specimen_id", title="Derived From Specimen Id"
    )
    derivation_concept_id: int | None = Field(
        None,
        description="derivation_concept_id",
        le=2147483647,
        title="Derivation Concept Id",
    )
    provenance_id: UUID = Field(..., description="provenance_id", title="Provenance Id")
    source_traceback: str = Field(
        ..., description="source_traceback", title="Source Traceback"
    )


class FactRelationship(Model):

    ENTITY: ClassVar = Entity(
        snake_case_plural_name="FactRelationships",
        table_name="fact_relationship",
        persistable=True,
        keys=create_keys({}),
        **_ENTITY_KWARGS,
    )

    domain_concept_id_1: int = Field(
        ...,
        description="domain_concept_id_1",
        le=2147483647,
        title="Domain Concept Id 1",
    )
    domain_concept_id_2: int = Field(
        ...,
        description="domain_concept_id_2",
        le=2147483647,
        title="Domain Concept Id 2",
    )
    fact_id_1: int = Field(..., description="fact_id_1", title="Fact Id 1")
    fact_id_2: int = Field(..., description="fact_id_2", title="Fact Id 2")
    relationship_concept_id: int = Field(
        ...,
        description="relationship_concept_id",
        le=2147483647,
        title="Relationship Concept Id",
    )
    provenance_id: UUID = Field(..., description="provenance_id", title="Provenance Id")


class SurveyConduct(Model):

    ENTITY: ClassVar = Entity(
        snake_case_plural_name="SurveyConducts",
        table_name="survey_conduct",
        persistable=True,
        keys=create_keys({1: "survey_conduct_id"}),
        **_ENTITY_KWARGS,
    )

    assisted_concept_id: int = Field(
        ...,
        description="assisted_concept_id",
        le=2147483647,
        title="Assisted Concept Id",
    )
    collection_method_concept_id: int = Field(
        ...,
        description="collection_method_concept_id",
        le=2147483647,
        title="Collection Method Concept Id",
    )
    respondent_type_concept_id: int = Field(
        ...,
        description="respondent_type_concept_id",
        le=2147483647,
        title="Respondent Type Concept Id",
    )
    survey_concept_id: int = Field(
        ..., description="survey_concept_id", le=2147483647, title="Survey Concept Id"
    )
    survey_source_concept_id: int = Field(
        ...,
        description="survey_source_concept_id",
        le=2147483647,
        title="Survey Source Concept Id",
    )
    timing_concept_id: int = Field(
        ..., description="timing_concept_id", le=2147483647, title="Timing Concept Id"
    )
    validated_survey_concept_id: int = Field(
        ...,
        description="validated_survey_concept_id",
        le=2147483647,
        title="Validated Survey Concept Id",
    )
    person_id: UUID = Field(..., description="person_id", title="Person Id")
    survey_conduct_id: UUID = Field(
        ..., description="survey_conduct_id, PRIMARY KEY", title="Survey Conduct Id"
    )
    survey_end_date: date | None = Field(
        None, description="survey_end_date", title="Survey End Date"
    )
    survey_end_datetime: datetime = Field(
        ..., description="survey_end_datetime", title="Survey End Datetime"
    )
    survey_start_date: date | None = Field(
        None, description="survey_start_date", title="Survey Start Date"
    )
    survey_start_datetime: datetime | None = Field(
        None, description="survey_start_datetime", title="Survey Start Datetime"
    )
    provider_id: UUID | None = Field(
        None, description="provider_id", title="Provider Id"
    )
    respondent_type_source_value: str | None = Field(
        None,
        description="respondent_type_source_value",
        max_length=100,
        title="Respondent Type Source Value",
    )
    timing_source_value: str | None = Field(
        None,
        description="timing_source_value",
        max_length=100,
        title="Timing Source Value",
    )
    collection_method_source_value: str | None = Field(
        None,
        description="collection_method_source_value",
        max_length=100,
        title="Collection Method Source Value",
    )
    survey_source_value: str | None = Field(
        None,
        description="survey_source_value",
        max_length=100,
        title="Survey Source Value",
    )
    survey_source_identifier: str | None = Field(
        None,
        description="survey_source_identifier",
        max_length=100,
        title="Survey Source Identifier",
    )
    validated_survey_source_value: str | None = Field(
        None,
        description="validated_survey_source_value",
        max_length=100,
        title="Validated Survey Source Value",
    )
    survey_version_number: str | None = Field(
        None,
        description="survey_version_number",
        max_length=20,
        title="Survey Version Number",
    )
    assisted_source_value: str | None = Field(
        None,
        description="assisted_source_value",
        max_length=50,
        title="Assisted Source Value",
    )
    response_visit_occurrence_id: UUID | None = Field(
        None,
        description="response_visit_occurrence_id",
        title="Response Visit Occurrence Id",
    )
    visit_occurrence_id: UUID | None = Field(
        None, description="visit_occurrence_id", title="Visit Occurrence Id"
    )
    provenance_id: UUID = Field(..., description="provenance_id", title="Provenance Id")
    source_traceback: str = Field(
        ..., description="source_traceback", title="Source Traceback"
    )


class Location(Model):

    ENTITY: ClassVar = Entity(
        snake_case_plural_name="Locations",
        table_name="location",
        persistable=True,
        keys=create_keys({1: "location_id"}),
        **_ENTITY_KWARGS,
    )

    location_id: UUID = Field(
        ..., description="location_id, PRIMARY KEY", title="Location Id"
    )
    latitude: float | None = Field(
        None, description="latitude", ge=-90.0, le=90.0, title="Latitude"
    )
    longitude: float | None = Field(
        None, description="longitude", ge=-180.0, le=180.0, title="Longitude"
    )
    state: str | None = Field(None, description="state", max_length=2, title="State")
    county: str | None = Field(
        None, description="county", max_length=20, title="County"
    )
    address_1: str | None = Field(
        None, description="address_1", max_length=50, title="Address 1"
    )
    address_2: str | None = Field(
        None, description="address_2", max_length=50, title="Address 2"
    )
    city: str | None = Field(None, description="city", max_length=50, title="City")
    location_source_value: str | None = Field(
        None,
        description="location_source_value",
        max_length=50,
        title="Location Source Value",
    )
    zip: str | None = Field(None, description="zip", max_length=9, title="Zip")
    provenance_id: UUID = Field(..., description="provenance_id", title="Provenance Id")
    source_traceback: str = Field(
        ..., description="source_traceback", title="Source Traceback"
    )


class LocationHistory(Model):

    ENTITY: ClassVar = Entity(
        snake_case_plural_name="LocationHistorys",
        table_name="location_history",
        persistable=True,
        keys=create_keys({}),
        **_ENTITY_KWARGS,
    )

    end_date: date | None = Field(None, description="end_date", title="End Date")
    end_iso_interval: str | None = Field(
        None, description="end_iso_interval", max_length=55, title="End Iso Interval"
    )
    entity_id: UUID = Field(..., description="entity_id", title="Entity Id")
    start_date: date = Field(..., description="start_date", title="Start Date")
    start_iso_interval: str = Field(
        ..., description="start_iso_interval", max_length=55, title="Start Iso Interval"
    )
    domain_id: str = Field(
        ..., description="domain_id", max_length=50, title="Domain Id"
    )
    relationship_type_concept_id: int = Field(
        ...,
        description="relationship_type_concept_id",
        le=2147483647,
        title="Relationship Type Concept Id",
    )
    location_id: UUID = Field(..., description="location_id", title="Location Id")
    location_history_id: UUID = Field(
        ..., description="location_history_id, PRIMARY KEY", title="Location History Id"
    )
    provenance_id: UUID = Field(..., description="provenance_id", title="Provenance Id")
    source_traceback: str = Field(
        ..., description="source_traceback", title="Source Traceback"
    )


class CareSite(Model):

    ENTITY: ClassVar = Entity(
        snake_case_plural_name="CareSites",
        table_name="care_site",
        persistable=True,
        keys=create_keys({1: "care_site_id"}),
        **_ENTITY_KWARGS,
    )

    care_site_id: UUID = Field(
        ..., description="care_site_id, PRIMARY KEY", title="Care Site Id"
    )
    care_site_name: str | None = Field(
        None, description="care_site_name", max_length=255, title="Care Site Name"
    )
    care_site_source_value: str | None = Field(
        None,
        description="care_site_source_value",
        max_length=50,
        title="Care Site Source Value",
    )
    place_of_service_source_value: str | None = Field(
        None,
        description="place_of_service_source_value",
        max_length=50,
        title="Place Of Service Source Value",
    )
    place_of_service_concept_id: int = Field(
        ...,
        description="place_of_service_concept_id",
        le=2147483647,
        title="Place Of Service Concept Id",
    )
    location_id: UUID | None = Field(
        None, description="location_id", title="Location Id"
    )
    organization_id: UUID = Field(
        ..., description="organization_id", title="Organization Id"
    )
    provenance_id: UUID = Field(..., description="provenance_id", title="Provenance Id")
    source_traceback: str = Field(
        ..., description="source_traceback", title="Source Traceback"
    )


class Provider(Model):

    ENTITY: ClassVar = Entity(
        snake_case_plural_name="Providers",
        table_name="provider",
        persistable=True,
        keys=create_keys({1: "provider_id"}),
        **_ENTITY_KWARGS,
    )

    gender_concept_id: int = Field(
        ..., description="gender_concept_id", le=2147483647, title="Gender Concept Id"
    )
    gender_source_concept_id: int = Field(
        ...,
        description="gender_source_concept_id",
        le=2147483647,
        title="Gender Source Concept Id",
    )
    specialty_concept_id: int = Field(
        ...,
        description="specialty_concept_id",
        le=2147483647,
        title="Specialty Concept Id",
    )
    specialty_source_concept_id: int = Field(
        ...,
        description="specialty_source_concept_id",
        le=2147483647,
        title="Specialty Source Concept Id",
    )
    care_site_id: UUID | None = Field(
        None, description="care_site_id", title="Care Site Id"
    )
    provider_id: UUID = Field(
        ..., description="provider_id, PRIMARY KEY", title="Provider Id"
    )
    year_of_birth: int | None = Field(
        None, description="year_of_birth", title="Year Of Birth"
    )
    npi: str | None = Field(None, description="npi", max_length=20, title="Npi")
    dea: str | None = Field(None, description="dea", max_length=20, title="Dea")
    provider_name: str | None = Field(
        None, description="provider_name", max_length=255, title="Provider Name"
    )
    provider_source_value: str | None = Field(
        None,
        description="provider_source_value",
        max_length=50,
        title="Provider Source Value",
    )
    specialty_source_value: str | None = Field(
        None,
        description="specialty_source_value",
        max_length=50,
        title="Specialty Source Value",
    )
    gender_source_value: str | None = Field(
        None,
        description="gender_source_value",
        max_length=50,
        title="Gender Source Value",
    )
    provenance_id: UUID = Field(..., description="provenance_id", title="Provenance Id")
    source_traceback: str = Field(
        ..., description="source_traceback", title="Source Traceback"
    )


class PayerPlanPeriod(Model):

    ENTITY: ClassVar = Entity(
        snake_case_plural_name="PayerPlanPeriods",
        table_name="payer_plan_period",
        persistable=True,
        keys=create_keys({1: "payer_plan_period_id"}),
        **_ENTITY_KWARGS,
    )

    contract_concept_id: int = Field(
        ...,
        description="contract_concept_id",
        le=2147483647,
        title="Contract Concept Id",
    )
    payer_concept_id: int = Field(
        ..., description="payer_concept_id", le=2147483647, title="Payer Concept Id"
    )
    payer_source_concept_id: int = Field(
        ...,
        description="payer_source_concept_id",
        le=2147483647,
        title="Payer Source Concept Id",
    )
    plan_concept_id: int = Field(
        ..., description="plan_concept_id", le=2147483647, title="Plan Concept Id"
    )
    plan_source_concept_id: int = Field(
        ...,
        description="plan_source_concept_id",
        le=2147483647,
        title="Plan Source Concept Id",
    )
    sponsor_concept_id: int = Field(
        ..., description="sponsor_concept_id", le=2147483647, title="Sponsor Concept Id"
    )
    sponsor_source_concept_id: int | None = Field(
        None,
        description="sponsor_source_concept_id",
        le=2147483647,
        title="Sponsor Source Concept Id",
    )
    stop_reason_concept_id: int | None = Field(
        None,
        description="stop_reason_concept_id",
        le=2147483647,
        title="Stop Reason Concept Id",
    )
    stop_reason_source_concept_id: int | None = Field(
        None,
        description="stop_reason_source_concept_id",
        le=2147483647,
        title="Stop Reason Source Concept Id",
    )
    payer_plan_period_end_date: date = Field(
        ...,
        description="payer_plan_period_end_date",
        title="Payer Plan Period End Date",
    )
    payer_plan_period_start_date: date = Field(
        ...,
        description="payer_plan_period_start_date",
        title="Payer Plan Period Start Date",
    )
    payer_source_value: str | None = Field(
        None,
        description="payer_source_value",
        max_length=50,
        title="Payer Source Value",
    )
    plan_source_value: str | None = Field(
        None, description="plan_source_value", max_length=50, title="Plan Source Value"
    )
    contract_source_value: str = Field(
        ...,
        description="contract_source_value",
        max_length=50,
        title="Contract Source Value",
    )
    sponsor_source_value: str | None = Field(
        None,
        description="sponsor_source_value",
        max_length=50,
        title="Sponsor Source Value",
    )
    family_source_value: str | None = Field(
        None,
        description="family_source_value",
        max_length=50,
        title="Family Source Value",
    )
    stop_reason_source_value: str | None = Field(
        None,
        description="stop_reason_source_value",
        max_length=50,
        title="Stop Reason Source Value",
    )
    contract_person_id: UUID | None = Field(
        None, description="contract_person_id", title="Contract Person Id"
    )
    contract_source_concept_id: int = Field(
        ...,
        description="contract_source_concept_id",
        le=2147483647,
        title="Contract Source Concept Id",
    )
    payer_plan_period_id: UUID = Field(
        ...,
        description="payer_plan_period_id, PRIMARY KEY",
        title="Payer Plan Period Id",
    )
    person_id: UUID = Field(..., description="person_id", title="Person Id")


class Cost(Model):

    ENTITY: ClassVar = Entity(
        snake_case_plural_name="Costs",
        table_name="cost",
        persistable=True,
        keys=create_keys({1: "cost_id"}),
        **_ENTITY_KWARGS,
    )

    cost_concept_id: int | None = Field(
        None, description="cost_concept_id", le=2147483647, title="Cost Concept Id"
    )
    billed_date: date | None = Field(
        None, description="billed_date", title="Billed Date"
    )
    cost_event_field_concept_id: int = Field(
        ...,
        description="cost_event_field_concept_id",
        le=2147483647,
        title="Cost Event Field Concept Id",
    )
    cost_source_concept_id: int | None = Field(
        None,
        description="cost_source_concept_id",
        le=2147483647,
        title="Cost Source Concept Id",
    )
    cost_type_concept_id: int | None = Field(
        None,
        description="cost_type_concept_id",
        le=2147483647,
        title="Cost Type Concept Id",
    )
    cost_id: UUID = Field(..., description="cost_id, PRIMARY KEY", title="Cost Id")
    person_id: int = Field(..., description="person_id", title="Person Id")
    cost_event_id: int = Field(..., description="cost_event_id", title="Cost Event Id")
    payer_plan_period_id: int | None = Field(
        None, description="payer_plan_period_id", title="Payer Plan Period Id"
    )
    incurred_date: date | None = Field(
        None, description="incurred_date", title="Incurred Date"
    )
    paid_date: date | None = Field(None, description="paid_date", title="Paid Date")
    cost: float | None = Field(None, description="cost", title="Cost")
    currency_concept_id: int | None = Field(
        None,
        description="currency_concept_id",
        le=2147483647,
        title="Currency Concept Id",
    )
    cost_source_value: str | None = Field(
        None, description="cost_source_value", max_length=50, title="Cost Source Value"
    )
    revenue_code_source_value: str | None = Field(
        None,
        description="revenue_code_source_value",
        max_length=50,
        title="Revenue Code Source Value",
    )
    drg_source_value: str | None = Field(
        None, description="drg_source_value", max_length=50, title="Drg Source Value"
    )
    drg_concept_id: int | None = Field(
        None, description="drg_concept_id", le=2147483647, title="Drg Concept Id"
    )
    revenue_code_concept_id: int | None = Field(
        None,
        description="revenue_code_concept_id",
        le=2147483647,
        title="Revenue Code Concept Id",
    )
    provenance_id: UUID = Field(..., description="provenance_id", title="Provenance Id")
    source_traceback: str = Field(
        ..., description="source_traceback", title="Source Traceback"
    )


class DrugEra(Model):

    ENTITY: ClassVar = Entity(
        snake_case_plural_name="DrugEras",
        table_name="drug_era",
        persistable=True,
        keys=create_keys({1: "drug_era_id"}),
        **_ENTITY_KWARGS,
    )

    drug_concept_id: int = Field(
        ..., description="drug_concept_id", le=2147483647, title="Drug Concept Id"
    )
    drug_era_end_datetime: datetime = Field(
        ..., description="drug_era_end_datetime", title="Drug Era End Datetime"
    )
    drug_era_id: UUID = Field(
        ..., description="drug_era_id, PRIMARY KEY", title="Drug Era Id"
    )
    drug_era_end_iso_interval: str = Field(
        ...,
        description="drug_era_end_iso_interval",
        max_length=55,
        title="Drug Era End Iso Interval",
    )
    drug_era_start_datetime: datetime = Field(
        ..., description="drug_era_start_datetime", title="Drug Era Start Datetime"
    )
    drug_era_start_iso_interval: str = Field(
        ...,
        description="drug_era_start_iso_interval",
        max_length=55,
        title="Drug Era Start Iso Interval",
    )
    drug_exposure_count: int | None = Field(
        None, description="drug_exposure_count", title="Drug Exposure Count"
    )
    gap_days: int | None = Field(None, description="gap_days", title="Gap Days")
    person_id: UUID = Field(..., description="person_id", title="Person Id")


class DoseEra(Model):

    ENTITY: ClassVar = Entity(
        snake_case_plural_name="DoseEras",
        table_name="dose_era",
        persistable=True,
        keys=create_keys({1: "dose_era_id"}),
        **_ENTITY_KWARGS,
    )

    dose_era_end_datetime: datetime = Field(
        ..., description="dose_era_end_datetime", title="Dose Era End Datetime"
    )
    drug_concept_id: int = Field(
        ..., description="drug_concept_id", le=2147483647, title="Drug Concept Id"
    )
    dose_era_id: UUID = Field(
        ..., description="dose_era_id, PRIMARY KEY", title="Dose Era Id"
    )
    dose_era_start_datetime: datetime = Field(
        ..., description="dose_era_start_datetime", title="Dose Era Start Datetime"
    )
    dose_value: float = Field(..., description="dose_value", title="Dose Value")
    unit_concept_id: int = Field(
        ..., description="unit_concept_id", le=2147483647, title="Unit Concept Id"
    )
    person_id: UUID = Field(..., description="person_id", title="Person Id")


class ConditionEra(Model):

    ENTITY: ClassVar = Entity(
        snake_case_plural_name="ConditionEras",
        table_name="condition_era",
        persistable=True,
        keys=create_keys({1: "condition_era_id"}),
        **_ENTITY_KWARGS,
    )

    condition_era_end_datetime: datetime = Field(
        ...,
        description="condition_era_end_datetime",
        title="Condition Era End Datetime",
    )
    condition_concept_id: int = Field(
        ...,
        description="condition_concept_id",
        le=2147483647,
        title="Condition Concept Id",
    )
    condition_era_id: UUID = Field(
        ..., description="condition_era_id, PRIMARY KEY", title="Condition Era Id"
    )
    person_id: int = Field(..., description="person_id", title="Person Id")
    condition_era_start_datetime: datetime = Field(
        ...,
        description="condition_era_start_datetime",
        title="Condition Era Start Datetime",
    )
    condition_occurrence_count: int | None = Field(
        None,
        description="condition_occurrence_count",
        title="Condition Occurrence Count",
    )


class Metadata(Model):

    ENTITY: ClassVar = Entity(
        snake_case_plural_name="Metadatas",
        table_name="metadata",
        persistable=True,
        keys=create_keys({}),
        **_ENTITY_KWARGS,
    )

    metadata_concept_id: int = Field(
        ...,
        description="metadata_concept_id",
        le=2147483647,
        title="Metadata Concept Id",
    )
    metadata_type_concept_id: int = Field(
        ...,
        description="metadata_type_concept_id",
        le=2147483647,
        title="Metadata Type Concept Id",
    )
    metadata_date: date | None = Field(
        None, description="metadata_date", title="Metadata Date"
    )
    metadata_datetime: datetime | None = Field(
        None, description="metadata_datetime", title="Metadata Datetime"
    )
    name: str = Field(..., description="name", max_length=250, title="Name")
    value_as_string: str | None = Field(
        None, description="value_as_string", max_length=250, title="Value As String"
    )
    value_as_concept_id: int | None = Field(
        None,
        description="value_as_concept_id",
        le=2147483647,
        title="Value As Concept Id",
    )


class CdmSource(Model):

    ENTITY: ClassVar = Entity(
        snake_case_plural_name="CdmSources",
        table_name="cdm_source",
        persistable=True,
        keys=create_keys({}),
        **_ENTITY_KWARGS,
    )

    cdm_release_date: date | None = Field(
        None, description="cdm_release_date", title="Cdm Release Date"
    )
    source_release_date: date | None = Field(
        None, description="source_release_date", title="Source Release Date"
    )
    cdm_version: str | None = Field(
        None, description="cdm_version", max_length=10, title="Cdm Version"
    )
    vocabulary_version: str | None = Field(
        None,
        description="vocabulary_version",
        max_length=20,
        title="Vocabulary Version",
    )
    cdm_source_abbreviation: str | None = Field(
        None,
        description="cdm_source_abbreviation",
        max_length=25,
        title="Cdm Source Abbreviation",
    )
    cdm_source_name: str = Field(
        ..., description="cdm_source_name", max_length=255, title="Cdm Source Name"
    )
    cdm_holder: str | None = Field(
        None, description="cdm_holder", max_length=255, title="Cdm Holder"
    )
    source_documentation_reference: str | None = Field(
        None,
        description="source_documentation_reference",
        max_length=255,
        title="Source Documentation Reference",
    )
    cdm_etl_reference: str | None = Field(
        None, description="cdm_etl_reference", max_length=255, title="Cdm Etl Reference"
    )
    source_description: str | None = Field(
        None, description="source_description", title="Source Description"
    )


class Concept(Model):

    ENTITY: ClassVar = Entity(
        snake_case_plural_name="Concepts",
        table_name="concept",
        persistable=True,
        keys=create_keys({1: "concept_id"}),
        **_ENTITY_KWARGS,
    )

    valid_end_date: date = Field(
        ..., description="valid_end_date", title="Valid End Date"
    )
    valid_start_date: date = Field(
        ..., description="valid_start_date", title="Valid Start Date"
    )
    concept_id: int = Field(
        ..., description="concept_id, PRIMARY KEY", title="Concept Id"
    )
    standard_concept: str | None = Field(
        None, description="standard_concept", max_length=1, title="Standard Concept"
    )
    invalid_reason: str | None = Field(
        None, description="invalid_reason", max_length=1, title="Invalid Reason"
    )
    concept_name: str = Field(
        ..., description="concept_name", max_length=255, title="Concept Name"
    )
    concept_code: str = Field(
        ..., description="concept_code", max_length=50, title="Concept Code"
    )
    concept_class_id: str = Field(
        ..., description="concept_class_id", max_length=20, title="Concept Class Id"
    )
    domain_id: str = Field(
        ..., description="domain_id", max_length=20, title="Domain Id"
    )
    vocabulary_id: str = Field(
        ..., description="vocabulary_id", max_length=20, title="Vocabulary Id"
    )


class Vocabulary(Model):

    ENTITY: ClassVar = Entity(
        snake_case_plural_name="Vocabularys",
        table_name="vocabulary",
        persistable=True,
        keys=create_keys({1: "vocabulary_id"}),
        **_ENTITY_KWARGS,
    )

    vocabulary_concept_id: int = Field(
        ...,
        description="vocabulary_concept_id",
        le=2147483647,
        title="Vocabulary Concept Id",
    )
    vocabulary_id: str = Field(
        ...,
        description="vocabulary_id, PRIMARY KEY",
        max_length=20,
        title="Vocabulary Id",
    )
    vocabulary_name: str = Field(
        ..., description="vocabulary_name", max_length=255, title="Vocabulary Name"
    )
    vocabulary_reference: str = Field(
        ...,
        description="vocabulary_reference",
        max_length=255,
        title="Vocabulary Reference",
    )
    vocabulary_version: str | None = Field(
        None,
        description="vocabulary_version",
        max_length=255,
        title="Vocabulary Version",
    )


class Domain(Model):

    ENTITY: ClassVar = Entity(
        snake_case_plural_name="Domains",
        table_name="domain",
        persistable=True,
        keys=create_keys({1: "domain_id"}),
        **_ENTITY_KWARGS,
    )

    domain_concept_id: int = Field(
        ..., description="domain_concept_id", le=2147483647, title="Domain Concept Id"
    )
    domain_id: str = Field(
        ..., description="domain_id, PRIMARY KEY", max_length=20, title="Domain Id"
    )
    domain_name: str = Field(
        ..., description="domain_name", max_length=255, title="Domain Name"
    )


class ConceptClass(Model):

    ENTITY: ClassVar = Entity(
        snake_case_plural_name="ConceptClasss",
        table_name="concept_class",
        persistable=True,
        keys=create_keys({1: "concept_class_id"}),
        **_ENTITY_KWARGS,
    )

    concept_class_concept_id: int = Field(
        ...,
        description="concept_class_concept_id",
        le=2147483647,
        title="Concept Class Concept Id",
    )
    concept_class_id: str = Field(
        ...,
        description="concept_class_id, PRIMARY KEY",
        max_length=20,
        title="Concept Class Id",
    )
    concept_class_name: str = Field(
        ...,
        description="concept_class_name",
        max_length=255,
        title="Concept Class Name",
    )


class ConceptRelationship(Model):

    ENTITY: ClassVar = Entity(
        snake_case_plural_name="ConceptRelationships",
        table_name="concept_relationship",
        persistable=True,
        keys=create_keys({}),
        **_ENTITY_KWARGS,
    )

    valid_end_date: date = Field(
        ..., description="valid_end_date", title="Valid End Date"
    )
    valid_start_date: date = Field(
        ..., description="valid_start_date", title="Valid Start Date"
    )
    concept_id_1: int = Field(
        ..., description="concept_id_1", le=2147483647, title="Concept Id 1"
    )
    invalid_reason: str | None = Field(
        None, description="invalid_reason", max_length=1, title="Invalid Reason"
    )
    concept_id_2: int = Field(
        ..., description="concept_id_2", le=2147483647, title="Concept Id 2"
    )
    relationship_id: str = Field(
        ..., description="relationship_id", max_length=20, title="Relationship Id"
    )


class Relationship(Model):

    ENTITY: ClassVar = Entity(
        snake_case_plural_name="Relationships",
        table_name="relationship",
        persistable=True,
        keys=create_keys({1: "relationship_id"}),
        **_ENTITY_KWARGS,
    )

    relationship_concept_id: int = Field(
        ...,
        description="relationship_concept_id",
        le=2147483647,
        title="Relationship Concept Id",
    )
    is_hierarchical: str = Field(
        ..., description="is_hierarchical", max_length=1, title="Is Hierarchical"
    )
    defines_ancestry: str = Field(
        ..., description="defines_ancestry", max_length=1, title="Defines Ancestry"
    )
    relationship_id: str = Field(
        ...,
        description="relationship_id, PRIMARY KEY",
        max_length=20,
        title="Relationship Id",
    )
    reverse_relationship_id: str = Field(
        ...,
        description="reverse_relationship_id",
        max_length=20,
        title="Reverse Relationship Id",
    )
    relationship_name: str = Field(
        ..., description="relationship_name", max_length=255, title="Relationship Name"
    )


class ConceptSynonym(Model):

    ENTITY: ClassVar = Entity(
        snake_case_plural_name="ConceptSynonyms",
        table_name="concept_synonym",
        persistable=True,
        keys=create_keys({}),
        **_ENTITY_KWARGS,
    )

    concept_id: int = Field(
        ..., description="concept_id", le=2147483647, title="Concept Id"
    )
    concept_synonym_name: str = Field(
        ...,
        description="concept_synonym_name",
        max_length=1000,
        title="Concept Synonym Name",
    )
    language_concept_id: int = Field(
        ...,
        description="language_concept_id",
        le=2147483647,
        title="Language Concept Id",
    )


class ConceptAncestor(Model):

    ENTITY: ClassVar = Entity(
        snake_case_plural_name="ConceptAncestors",
        table_name="concept_ancestor",
        persistable=True,
        keys=create_keys({}),
        **_ENTITY_KWARGS,
    )

    ancestor_concept_id: int = Field(
        ...,
        description="ancestor_concept_id",
        le=2147483647,
        title="Ancestor Concept Id",
    )
    min_levels_of_separation: int = Field(
        ..., description="min_levels_of_separation", title="Min Levels Of Separation"
    )
    max_levels_of_separation: int = Field(
        ..., description="max_levels_of_separation", title="Max Levels Of Separation"
    )
    descendant_concept_id: int = Field(
        ...,
        description="descendant_concept_id",
        le=2147483647,
        title="Descendant Concept Id",
    )


class SourceToConceptMap(Model):

    ENTITY: ClassVar = Entity(
        snake_case_plural_name="SourceToConceptMaps",
        table_name="source_to_concept_map",
        persistable=True,
        keys=create_keys({}),
        **_ENTITY_KWARGS,
    )

    source_concept_id: int = Field(
        ..., description="source_concept_id", le=2147483647, title="Source Concept Id"
    )
    target_concept_id: int = Field(
        ..., description="target_concept_id", le=2147483647, title="Target Concept Id"
    )
    valid_end_date: date = Field(
        ..., description="valid_end_date", title="Valid End Date"
    )
    valid_start_date: date = Field(
        ..., description="valid_start_date", title="Valid Start Date"
    )
    invalid_reason: str | None = Field(
        None, description="invalid_reason", max_length=1, title="Invalid Reason"
    )
    source_vocabulary_id: str = Field(
        ...,
        description="source_vocabulary_id",
        max_length=20,
        title="Source Vocabulary Id",
    )
    source_code_description: str | None = Field(
        None,
        description="source_code_description",
        max_length=255,
        title="Source Code Description",
    )
    source_code: str = Field(
        ..., description="source_code", max_length=50, title="Source Code"
    )
    target_vocabulary_id: str = Field(
        ...,
        description="target_vocabulary_id",
        max_length=20,
        title="Target Vocabulary Id",
    )


class DrugStrength(Model):

    ENTITY: ClassVar = Entity(
        snake_case_plural_name="DrugStrengths",
        table_name="drug_strength",
        persistable=True,
        keys=create_keys({}),
        **_ENTITY_KWARGS,
    )

    amount_unit_concept_id: int | None = Field(
        None,
        description="amount_unit_concept_id",
        le=2147483647,
        title="Amount Unit Concept Id",
    )
    denominator_unit_concept_id: int | None = Field(
        None,
        description="denominator_unit_concept_id",
        le=2147483647,
        title="Denominator Unit Concept Id",
    )
    drug_concept_id: int = Field(
        ..., description="drug_concept_id", le=2147483647, title="Drug Concept Id"
    )
    valid_end_date: date = Field(
        ..., description="valid_end_date", title="Valid End Date"
    )
    valid_start_date: date = Field(
        ..., description="valid_start_date", title="Valid Start Date"
    )
    ingredient_concept_id: int = Field(
        ...,
        description="ingredient_concept_id",
        le=2147483647,
        title="Ingredient Concept Id",
    )
    amount_value: float | None = Field(
        None, description="amount_value", title="Amount Value"
    )
    numerator_value: float | None = Field(
        None, description="numerator_value", title="Numerator Value"
    )
    denominator_value: float | None = Field(
        None, description="denominator_value", title="Denominator Value"
    )
    box_size: int | None = Field(None, description="box_size", title="Box Size")
    invalid_reason: str | None = Field(
        None, description="invalid_reason", max_length=1, title="Invalid Reason"
    )
    numerator_unit_concept_id: int | None = Field(
        None,
        description="numerator_unit_concept_id",
        le=2147483647,
        title="Numerator Unit Concept Id",
    )


class Cohort(Model):

    ENTITY: ClassVar = Entity(
        snake_case_plural_name="Cohorts",
        table_name="cohort",
        persistable=True,
        keys=create_keys({}),
        **_ENTITY_KWARGS,
    )

    cohort_end_date: date = Field(
        ..., description="cohort_end_date", title="Cohort End Date"
    )
    cohort_start_date: date = Field(
        ..., description="cohort_start_date", title="Cohort Start Date"
    )
    cohort_definition_id: UUID = Field(
        ..., description="cohort_definition_id", title="Cohort Definition Id"
    )
    subject_id: UUID = Field(..., description="subject_id", title="Subject Id")


class CohortDefinition(Model):

    ENTITY: ClassVar = Entity(
        snake_case_plural_name="CohortDefinitions",
        table_name="cohort_definition",
        persistable=True,
        keys=create_keys({}),
        **_ENTITY_KWARGS,
    )

    cohort_initiation_date: date | None = Field(
        None, description="cohort_initiation_date", title="Cohort Initiation Date"
    )
    cohort_definition_name: str = Field(
        ...,
        description="cohort_definition_name",
        max_length=255,
        title="Cohort Definition Name",
    )
    cohort_definition_description: str | None = Field(
        None,
        description="cohort_definition_description",
        title="Cohort Definition Description",
    )
    cohort_definition_syntax: str | None = Field(
        None, description="cohort_definition_syntax", title="Cohort Definition Syntax"
    )
    definition_type_concept_id: int = Field(
        ...,
        description="definition_type_concept_id",
        le=2147483647,
        title="Definition Type Concept Id",
    )
    subject_concept_id: int = Field(
        ..., description="subject_concept_id", le=2147483647, title="Subject Concept Id"
    )
    cohort_definition_id: UUID = Field(
        ..., description="cohort_definition_id", title="Cohort Definition Id"
    )


class Provenance(Model):

    ENTITY: ClassVar = Entity(
        snake_case_plural_name="Provenances",
        table_name="provenance",
        persistable=True,
        keys=create_keys({}),
        **_ENTITY_KWARGS,
    )

    provenance_id: UUID = Field(
        ..., description="provenance_id, PRIMARY KEY", title="Provenance Id"
    )
    source_id: UUID = Field(..., description="source_id", title="Source Id")
    etl_id: UUID = Field(..., description="etl_id", title="Etl Id")
    etl_start_datetime: datetime = Field(
        ..., description="etl_start_datetime", title="Etl Start Datetime"
    )
    etl_end_datetime: datetime = Field(
        ..., description="etl_end_datetime", title="Etl End Datetime"
    )


class Etl(Model):

    ENTITY: ClassVar = Entity(
        snake_case_plural_name="Etls",
        table_name="etl",
        persistable=True,
        keys=create_keys({1: "etl_id"}),
        **_ENTITY_KWARGS,
    )

    etl_id: UUID = Field(..., description="etl_id, PRIMARY KEY", title="Etl Id")
    etl_desc: str = Field(..., description="etl_desc", title="Etl Desc")
    etl_abbrev: str = Field(
        ..., description="etl_abbrev", max_length=32, title="Etl Abbrev"
    )
    etl_version: str = Field(
        ..., description="etl_version", max_length=32, title="Etl Version"
    )
    etl_release_datetime: datetime = Field(
        ..., description="etl_release_datetime", title="Etl Release Datetime"
    )


class Source(Model):

    ENTITY: ClassVar = Entity(
        snake_case_plural_name="Sources",
        table_name="source",
        persistable=True,
        keys=create_keys({1: "source_id"}),
        **_ENTITY_KWARGS,
    )

    source_id: UUID = Field(
        ..., description="source_id, PRIMARY KEY", title="Source Id"
    )
    source_desc: str = Field(..., description="source_desc", title="Source Desc")
    source_abbrev: str = Field(
        ..., description="source_abbrev", max_length=32, title="Source Abbrev"
    )


class Organization(Model):

    ENTITY: ClassVar = Entity(
        snake_case_plural_name="Organizations",
        table_name="organization",
        persistable=True,
        keys=create_keys({}),
        **_ENTITY_KWARGS,
    )

    organization_id: UUID = Field(
        ..., description="organization_id, PRIMARY KEY", title="Organization Id"
    )
    provenance_id: UUID = Field(..., description="provenance_id", title="Provenance Id")
    source_traceback: str = Field(
        ..., description="source_traceback", title="Source Traceback"
    )


class Subject(Model):

    id: int
    person: Person | None = Field(
        default=None,
    )
    specimen_records: list[Specimen]
    observation_records: list[Observation]
    measurement_records: list[Measurement]
    drug_exposure_records: list[DrugExposure]
    location_history_records: list[LocationHistory]


DOMAIN.register_locals(locals(), service_type=_SERVICE_TYPE)
