From 5ba789c765a9701d9cdb79c0f9be03a62b0e8ac8 Mon Sep 17 00:00:00 2001 From: linkmluser Date: Thu, 13 Jun 2024 22:26:16 -0400 Subject: [PATCH] pre-refactor --- src/data/examples/valid/EntitySet-001.yaml | 6 + .../examples/valid/EntitySet-EnvSample.yaml | 19 + .../EntitySet-ExtractiveIndustries-001.yaml | 92 ++ .../valid/EntitySet-PowerPlant-001.yaml | 118 +++ src/linkml_common/datamodel/bibliographic.py | 445 ++++++++ .../datamodel/civilengineering.py | 565 ++++++++++ .../datamodel/clinicalresearch.py | 877 ++++++++++++++++ src/linkml_common/datamodel/computational.py | 191 ++++ src/linkml_common/datamodel/core.py | 176 ++++ src/linkml_common/datamodel/datasets.py | 693 +++++++++++++ .../datamodel/energytechnology.py | 969 ++++++++++++++++++ src/linkml_common/datamodel/engineering.py | 462 +++++++++ src/linkml_common/datamodel/environmental.py | 331 ++++++ .../datamodel/extractiveindustry.py | 870 ++++++++++++++++ src/linkml_common/datamodel/financial.py | 520 ++++++++++ src/linkml_common/datamodel/foods.py | 591 +++++++++++ src/linkml_common/datamodel/geography.py | 332 ++++++ src/linkml_common/datamodel/healthcare.py | 629 ++++++++++++ src/linkml_common/datamodel/investigations.py | 546 ++++++++++ src/linkml_common/datamodel/measurements.py | 339 ++++++ src/linkml_common/datamodel/patterns.py | 216 ++++ src/linkml_common/datamodel/plannedprocess.py | 431 ++++++++ src/linkml_common/datamodel/quantities.py | 318 ++++++ src/linkml_common/datamodel/social.py | 437 ++++++++ src/linkml_common/datamodel/statistics.py | 784 ++++++++++++++ src/linkml_common/datamodel/time.py | 318 ++++++ 26 files changed, 11275 insertions(+) create mode 100644 src/data/examples/valid/EntitySet-001.yaml create mode 100644 src/data/examples/valid/EntitySet-EnvSample.yaml create mode 100644 src/data/examples/valid/EntitySet-ExtractiveIndustries-001.yaml create mode 100644 src/data/examples/valid/EntitySet-PowerPlant-001.yaml create mode 100644 src/linkml_common/datamodel/bibliographic.py create mode 100644 src/linkml_common/datamodel/civilengineering.py create mode 100644 src/linkml_common/datamodel/clinicalresearch.py create mode 100644 src/linkml_common/datamodel/computational.py create mode 100644 src/linkml_common/datamodel/core.py create mode 100644 src/linkml_common/datamodel/datasets.py create mode 100644 src/linkml_common/datamodel/energytechnology.py create mode 100644 src/linkml_common/datamodel/engineering.py create mode 100644 src/linkml_common/datamodel/environmental.py create mode 100644 src/linkml_common/datamodel/extractiveindustry.py create mode 100644 src/linkml_common/datamodel/financial.py create mode 100644 src/linkml_common/datamodel/foods.py create mode 100644 src/linkml_common/datamodel/geography.py create mode 100644 src/linkml_common/datamodel/healthcare.py create mode 100644 src/linkml_common/datamodel/investigations.py create mode 100644 src/linkml_common/datamodel/measurements.py create mode 100644 src/linkml_common/datamodel/patterns.py create mode 100644 src/linkml_common/datamodel/plannedprocess.py create mode 100644 src/linkml_common/datamodel/quantities.py create mode 100644 src/linkml_common/datamodel/social.py create mode 100644 src/linkml_common/datamodel/statistics.py create mode 100644 src/linkml_common/datamodel/time.py diff --git a/src/data/examples/valid/EntitySet-001.yaml b/src/data/examples/valid/EntitySet-001.yaml new file mode 100644 index 0000000..78e8f30 --- /dev/null +++ b/src/data/examples/valid/EntitySet-001.yaml @@ -0,0 +1,6 @@ +members: + - id: example:Person001 + name: foo bar + type: Person + primary_email: foo.bar@example.com + age_in_years: 33 diff --git a/src/data/examples/valid/EntitySet-EnvSample.yaml b/src/data/examples/valid/EntitySet-EnvSample.yaml new file mode 100644 index 0000000..d8ba81e --- /dev/null +++ b/src/data/examples/valid/EntitySet-EnvSample.yaml @@ -0,0 +1,19 @@ +members: + - id: example:INV001 + name: investigation 1 + type: Investigation + - id: example:S001 + name: sample 1 + type: SampleMaterial + - id: example:COL001 + name: collection 1 + type: SampleCollectionProcess + material_collected: example:S001 + part_of: example:INV001 + uses_physical_device: example:DEV001 + ends_at: + description: break of dawn + date_value: "2020-01-01" + - id: example:DEV001 + name: shovel + type: PhysicalDevice diff --git a/src/data/examples/valid/EntitySet-ExtractiveIndustries-001.yaml b/src/data/examples/valid/EntitySet-ExtractiveIndustries-001.yaml new file mode 100644 index 0000000..27c1d68 --- /dev/null +++ b/src/data/examples/valid/EntitySet-ExtractiveIndustries-001.yaml @@ -0,0 +1,92 @@ +members: +- id: XF001 + name: Example Coal Mine + type: MiningFacility + facility_type: MINING_FACILITY + mining_method: UNDERGROUND + operator: ORG001 + products: + - id: PROD001 + type: ExtractiveIndustryProduct + product_type: COAL + grade: + value: 0.7 + unit: PERCENT + processing_method: PM001 + production_capacity: + value: 5000000 + unit: TONS_PER_YEAR + annual_production: + value: 4500000 + unit: TONS + reserves: + value: 500000000 + unit: TONS + depth: + value: 500 + unit: METERS + area: + value: 10000 + unit: SQUARE_METERS + located_at_place: LOC001 + +- id: XF002 + name: Example Oil Well + type: WellFacility + facility_type: WELL_FACILITY + well_type: OIL + operator: ORG002 + products: + - id: PROD002 + type: ExtractiveIndustryProduct + product_type: OIL + grade: + value: 0.85 + unit: SPECIFIC_GRAVITY + processing_method: PM002 + production_capacity: + value: 100000 + unit: BARRELS_PER_DAY + annual_production: + value: 30000000 + unit: BARRELS + reserves: + value: 1000000000 + unit: BARRELS + depth: + value: 2000 + unit: METERS + located_at_place: LOC002 + +- id: LOC001 + name: Example Location + type: Place + geolocation: + latitude: 37.7749 + longitude: -122.4194 + +- id: LOC002 + name: Example Location + type: Place + geolocation: + latitude: 31.9686 + longitude: -99.9018 + +- id: LOC003 + name: Example Location + type: Place + geolocation: + latitude: 33.7490 + longitude: -84.3880 + +- id: ORG001 + name: Example Mining Company + type: Organization + +- id: ORG002 + name: Example Oil Company + type: Organization + +- id: ORG003 + name: Example Aggregates Company + type: Organization \ No newline at end of file diff --git a/src/data/examples/valid/EntitySet-PowerPlant-001.yaml b/src/data/examples/valid/EntitySet-PowerPlant-001.yaml new file mode 100644 index 0000000..f9fb1ce --- /dev/null +++ b/src/data/examples/valid/EntitySet-PowerPlant-001.yaml @@ -0,0 +1,118 @@ +members: +- id: ppl:LocationA + name: Location A + type: Place + geolocation: + latitude: 40.7128 + longitude: -74.0060 +- id: ppl:PlantA + name: Power Plant A + type: FossilFuelPlant + plant_type: COAL + location: ppl:LocationA + operator: ppl:OperatorX + capacity: + value: 500 + unit: MW + commissioning_date: '1980-01-01' + capex: + value: 1000000000 + unit: USD + opex: + value: 50000000 + unit: USD + +- id: ppl:LocationB + name: Location B + type: Place + geolocation: + latitude: 35.6762 + longitude: 139.6503 +- id: ppl:PlantB + name: Power Plant B + type: FossilFuelPlant + plant_type: NATURAL_GAS + location: ppl:LocationB + operator: ppl:OperatorY + capacity: + value: 750 + unit: MW + commissioning_date: '1995-06-15' + capex: + value: 1500000000 + unit: USD + opex: + value: 60000000 + unit: USD + +- id: ppl:LocationC + name: Location C + type: Place + geolocation: + latitude: 48.8566 + longitude: 2.3522 +- id: ppl:PlantC + name: Power Plant C + type: NuclearPlant + plant_type: NUCLEAR + location: ppl:LocationC + operator: ppl:OperatorZ + capacity: + value: 1000 + unit: MW + commissioning_date: '2010-12-01' + capex: + value: 5000000000 + unit: USD + opex: + value: 100000000 + unit: USD + +- id: ppl:LocationD + name: Location D + type: Place + geolocation: + latitude: 47.3769 + longitude: 8.5417 +- id: ppl:DamD + name: Dam D + type: Landform +- id: ppl:PlantD + name: Power Plant D + type: HydroelectricPlant + plant_type: HYDROELECTRIC + dam: ppl:DamD + location: ppl:LocationD + operator: ppl:OperatorW + capacity: + value: 200 + unit: MW + commissioning_date: '2005-03-20' + capex: + value: 800000000 + unit: USD + opex: + value: 20000000 + unit: USD + +- id: ppl:OperatorX + name: Operator X + type: Organization +- id: ppl:OperatorY + name: Operator Y + type: Organization +- id: ppl:OperatorZ + name: Operator Z + type: Organization +- id: ppl:OperatorW + name: Operator W + type: Organization + +- id: ppl:GridA + name: Electrical Grid A + type: ElectricalGrid + plants: + - ppl:PlantA + - ppl:PlantB + - ppl:PlantC + - ppl:PlantD \ No newline at end of file diff --git a/src/linkml_common/datamodel/bibliographic.py b/src/linkml_common/datamodel/bibliographic.py new file mode 100644 index 0000000..a6faa39 --- /dev/null +++ b/src/linkml_common/datamodel/bibliographic.py @@ -0,0 +1,445 @@ +from __future__ import annotations +from datetime import ( + datetime, + date +) +from decimal import Decimal +from enum import Enum +import re +import sys +from typing import ( + Any, + List, + Literal, + Dict, + Optional, + Union +) +from pydantic.version import VERSION as PYDANTIC_VERSION +if int(PYDANTIC_VERSION[0])>=2: + from pydantic import ( + BaseModel, + ConfigDict, + Field, + field_validator + ) +else: + from pydantic import ( + BaseModel, + Field, + validator + ) + +metamodel_version = "None" +version = "None" + + +class WeakRefShimBaseModel(BaseModel): + __slots__ = '__weakref__' + +class ConfiguredBaseModel(WeakRefShimBaseModel, + validate_assignment = True, + validate_all = True, + underscore_attrs_are_private = True, + extra = "forbid", + arbitrary_types_allowed = True, + use_enum_values = True): + pass + + +class RelativeTimeEnum(str, Enum): + BEFORE = "BEFORE" + AFTER = "AFTER" + AT_SAME_TIME_AS = "AT_SAME_TIME_AS" + + +class HumanLanguageCodeEnum(str): + """ + An enumeration of languages + """ + pass + + +class PersonStatus(str, Enum): + # the person is living + ALIVE = "ALIVE" + # the person is deceased + DEAD = "DEAD" + # the vital status is not known + UNKNOWN = "UNKNOWN" + + +class Identified(ConfiguredBaseModel): + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + + +class Typed(ConfiguredBaseModel): + type: Literal["Typed"] = Field("Typed", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Entity(Typed): + """ + A physical, digital, conceptual, or other kind of thing with some common characteristics + """ + type: Literal["Entity"] = Field("Entity", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Intangible(Entity): + """ + An entity that is not a physical object, process, or information + """ + type: Literal["Intangible"] = Field("Intangible", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class NamedThing(Entity, Identified): + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["NamedThing"] = Field("NamedThing", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Concept(Intangible, Identified): + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Concept"] = Field("Concept", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class InformationEntity(Intangible, Identified): + """ + An entity that describes some information + """ + describes: Optional[Any] = Field(None, description="""The thing that is being described""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["InformationEntity"] = Field("InformationEntity", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class PhysicalDevice(NamedThing): + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["PhysicalDevice"] = Field("PhysicalDevice", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class StructuredValue(Intangible): + """ + A value that is a structured collection of other values + """ + type: Literal["StructuredValue"] = Field("StructuredValue", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Role(Intangible): + type: Literal["Role"] = Field("Role", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Relationship(Intangible): + type: Literal["Relationship"] = Field("Relationship", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Location(StructuredValue): + type: Literal["Location"] = Field("Location", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class PointLocation(Location): + type: Literal["PointLocation"] = Field("PointLocation", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Specification(InformationEntity): + """ + A specification of a thing + """ + describes: Optional[Any] = Field(None, description="""The thing that is being described""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Specification"] = Field("Specification", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Procedure(Specification): + """ + A canonical series of actions conducted in a certain order or manner + """ + describes: Optional[Any] = Field(None, description="""The thing that is being described""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Procedure"] = Field("Procedure", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class EntitySet(Intangible): + """ + A group of things. The collection may be heterogeneous or homogeneous. + """ + members: Optional[List[Union[Entity,Intangible,NamedThing,Event,LifeEvent,PhysicalDevice,Agent,CreativeWork,Person,Organization,AutomatedAgent,Concept,InformationEntity,StructuredValue,Role,Relationship,EntitySet,Quantity,QuantityRange,TimePointOrTemporalInterval,Service,TemporalInterval,TimePoint,SimpleQuantity,Ratio,Duration,TemporalRelationship,Location,PointLocation,Specification,Publication,Procedure,QuantityKind,UnitConcept]]] = Field(default_factory=list, description="""The members of the collection""") + type: Literal["EntitySet"] = Field("EntitySet", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class QuantityKind(Concept): + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["QuantityKind"] = Field("QuantityKind", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Quantity(Intangible): + has_quantity_kind: Optional[str] = Field(None, description="""The kind of quantity""") + type: Literal["Quantity"] = Field("Quantity", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class SimpleQuantity(Quantity): + """ + A quantity is a property that can be measured or counted + """ + value: Optional[float] = Field(None, description="""The value of the quantity""") + unit: Optional[str] = Field(None) + has_quantity_kind: Optional[str] = Field(None, description="""The kind of quantity""") + type: Literal["SimpleQuantity"] = Field("SimpleQuantity", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Ratio(Quantity): + """ + A tuple of two quantities + """ + numerator: Optional[Union[Quantity,SimpleQuantity,Ratio,Duration]] = Field(None, description="""The numerator of the ratio""") + denominator: Optional[Union[Quantity,SimpleQuantity,Ratio,Duration]] = Field(None, description="""The denominator of the ratio""") + has_quantity_kind: Optional[str] = Field(None, description="""The kind of quantity""") + type: Literal["Ratio"] = Field("Ratio", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class QuantityRange(Intangible): + """ + A quantity range is a property that can be measured or counted + """ + lower_bound: Optional[Union[Quantity,SimpleQuantity,Ratio,Duration]] = Field(None, description="""The lower bound of the range""") + upper_bound: Optional[Union[Quantity,SimpleQuantity,Ratio,Duration]] = Field(None, description="""The upper bound of the range""") + type: Literal["QuantityRange"] = Field("QuantityRange", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class UnitConcept(Concept): + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["UnitConcept"] = Field("UnitConcept", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Event(Entity, Identified): + """ + A thing that happens + """ + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + happens_at: Optional[TimePoint] = Field(None) + has_interval: Optional[TemporalInterval] = Field(None) + has_duration: Optional[Duration] = Field(None) + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Event"] = Field("Event", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class TimePointOrTemporalInterval(Intangible): + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + type: Literal["TimePointOrTemporalInterval"] = Field("TimePointOrTemporalInterval", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class TemporalInterval(TimePointOrTemporalInterval): + """ + A period of time + """ + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + type: Literal["TemporalInterval"] = Field("TemporalInterval", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class TimePoint(TimePointOrTemporalInterval): + """ + A point in time. Can be fully specified, or specified in relative terms. + """ + year_value: Optional[int] = Field(None) + date_value: Optional[date] = Field(None) + time_value: Optional[str] = Field(None) + datetime_value: Optional[datetime ] = Field(None) + marker_event: Optional[str] = Field(None) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + type: Literal["TimePoint"] = Field("TimePoint", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Duration(Quantity): + """ + A length of time + """ + has_quantity_kind: Optional[str] = Field(None, description="""The kind of quantity""") + type: Literal["Duration"] = Field("Duration", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class TemporalRelationship(Relationship): + """ + A relationship to another time point + """ + predicate: Optional[RelativeTimeEnum] = Field(None, description="""The relationship between the two time points""") + relative_to: Optional[Union[TemporalInterval, TimePoint, str]] = Field(None) + type: Literal["TemporalRelationship"] = Field("TemporalRelationship", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Agent(NamedThing): + """ + Represents an Agent + """ + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Agent"] = Field("Agent", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Person(Agent): + """ + Represents a Person + """ + primary_email: Optional[str] = Field(None, description="""The main email address of a person""") + birth_date: Optional[date] = Field(None, description="""Date on which a person is born""") + age_in_years: Optional[int] = Field(None, description="""Number of years since birth""") + vital_status: Optional[PersonStatus] = Field(None, description="""living or dead status""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Person"] = Field("Person", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + @validator('primary_email', allow_reuse=True) + def pattern_primary_email(cls, v): + pattern=re.compile(r"^\S+@[\S+\.]+\S+") + if isinstance(v,list): + for element in v: + if not pattern.match(element): + raise ValueError(f"Invalid primary_email format: {element}") + elif isinstance(v,str): + if not pattern.match(v): + raise ValueError(f"Invalid primary_email format: {v}") + return v + + +class Organization(Agent): + """ + Represents an Organization + """ + provides_services: Optional[List[Service]] = Field(default_factory=list) + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Organization"] = Field("Organization", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class AutomatedAgent(Agent): + """ + Represents an Automated Agent + """ + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["AutomatedAgent"] = Field("AutomatedAgent", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class LifeEvent(Event): + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + happens_at: Optional[TimePoint] = Field(None) + has_interval: Optional[TemporalInterval] = Field(None) + has_duration: Optional[Duration] = Field(None) + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["LifeEvent"] = Field("LifeEvent", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class CreationMetadata(ConfiguredBaseModel): + title: Optional[str] = Field(None, description="""The title of the item""") + abstract: Optional[str] = Field(None, description="""A summary of the item""") + rights: Optional[str] = Field(None, description="""Information about rights held in and over the item""") + creators: Optional[List[str]] = Field(default_factory=list, description="""The person or organization who created the work""") + contributors: Optional[List[str]] = Field(default_factory=list, description="""A person or organization that contributed to the creation of the work""") + contacts: Optional[List[str]] = Field(default_factory=list, description="""A contact point for a person or organization""") + keywords: Optional[List[str]] = Field(default_factory=list, description="""Keywords or tags used to describe this item""") + + +class CreativeWork(CreationMetadata, NamedThing): + """ + The most generic kind of creative work, including books, movies, photographs, software programs, etc. + """ + title: Optional[str] = Field(None, description="""The title of the item""") + abstract: Optional[str] = Field(None, description="""A summary of the item""") + rights: Optional[str] = Field(None, description="""Information about rights held in and over the item""") + creators: Optional[List[str]] = Field(default_factory=list, description="""The person or organization who created the work""") + contributors: Optional[List[str]] = Field(default_factory=list, description="""A person or organization that contributed to the creation of the work""") + contacts: Optional[List[str]] = Field(default_factory=list, description="""A contact point for a person or organization""") + keywords: Optional[List[str]] = Field(default_factory=list, description="""Keywords or tags used to describe this item""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["CreativeWork"] = Field("CreativeWork", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Service(Intangible): + """ + A service provided by an organization + """ + type: Literal["Service"] = Field("Service", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Publication(InformationEntity): + describes: Optional[Any] = Field(None, description="""The thing that is being described""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Publication"] = Field("Publication", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +# Update forward refs +# see https://pydantic-docs.helpmanual.io/usage/postponed_annotations/ +Identified.update_forward_refs() +Typed.update_forward_refs() +Entity.update_forward_refs() +Intangible.update_forward_refs() +NamedThing.update_forward_refs() +Concept.update_forward_refs() +InformationEntity.update_forward_refs() +PhysicalDevice.update_forward_refs() +StructuredValue.update_forward_refs() +Role.update_forward_refs() +Relationship.update_forward_refs() +Location.update_forward_refs() +PointLocation.update_forward_refs() +Specification.update_forward_refs() +Procedure.update_forward_refs() +EntitySet.update_forward_refs() +QuantityKind.update_forward_refs() +Quantity.update_forward_refs() +SimpleQuantity.update_forward_refs() +Ratio.update_forward_refs() +QuantityRange.update_forward_refs() +UnitConcept.update_forward_refs() +Event.update_forward_refs() +TimePointOrTemporalInterval.update_forward_refs() +TemporalInterval.update_forward_refs() +TimePoint.update_forward_refs() +Duration.update_forward_refs() +TemporalRelationship.update_forward_refs() +Agent.update_forward_refs() +Person.update_forward_refs() +Organization.update_forward_refs() +AutomatedAgent.update_forward_refs() +LifeEvent.update_forward_refs() +CreationMetadata.update_forward_refs() +CreativeWork.update_forward_refs() +Service.update_forward_refs() +Publication.update_forward_refs() + diff --git a/src/linkml_common/datamodel/civilengineering.py b/src/linkml_common/datamodel/civilengineering.py new file mode 100644 index 0000000..2c6c7d6 --- /dev/null +++ b/src/linkml_common/datamodel/civilengineering.py @@ -0,0 +1,565 @@ +from __future__ import annotations +from datetime import ( + datetime, + date +) +from decimal import Decimal +from enum import Enum +import re +import sys +from typing import ( + Any, + List, + Literal, + Dict, + Optional, + Union +) +from pydantic.version import VERSION as PYDANTIC_VERSION +if int(PYDANTIC_VERSION[0])>=2: + from pydantic import ( + BaseModel, + ConfigDict, + Field, + field_validator + ) +else: + from pydantic import ( + BaseModel, + Field, + validator + ) + +metamodel_version = "None" +version = "None" + + +class WeakRefShimBaseModel(BaseModel): + __slots__ = '__weakref__' + +class ConfiguredBaseModel(WeakRefShimBaseModel, + validate_assignment = True, + validate_all = True, + underscore_attrs_are_private = True, + extra = "forbid", + arbitrary_types_allowed = True, + use_enum_values = True): + pass + + +class RelativeTimeEnum(str, Enum): + BEFORE = "BEFORE" + AFTER = "AFTER" + AT_SAME_TIME_AS = "AT_SAME_TIME_AS" + + +class Entity(ConfiguredBaseModel): + """ + A physical, digital, conceptual, or other kind of thing with some common characteristics + """ + type: Literal["Entity"] = Field("Entity", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Variable(Entity): + allowed_units: Optional[List[str]] = Field(default_factory=list, description="""The units that are allowed for this variable""") + type: Literal["Variable"] = Field("Variable", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class NamedThing(Entity): + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["NamedThing"] = Field("NamedThing", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + +class Concept(NamedThing): + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Concept"] = Field("Concept", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + +class InformationEntity(NamedThing): + """ + An entity that describes some information + """ + describes: Optional[Any] = Field(None, description="""The thing that is being described""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["InformationEntity"] = Field("InformationEntity", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + +class PhysicalDevice(NamedThing): + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["PhysicalDevice"] = Field("PhysicalDevice", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + +class Intangible(Entity): + """ + An entity that is not a physical object, process, or information + """ + type: Literal["Intangible"] = Field("Intangible", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Role(Intangible): + type: Literal["Role"] = Field("Role", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Relationship(Intangible): + type: Literal["Relationship"] = Field("Relationship", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Location(ConfiguredBaseModel): + pass + + +class PointLocation(Location): + pass + + +class Observation(Entity): + """ + A statement about the state of something + """ + type: Literal["Observation"] = Field("Observation", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Measurement(Observation): + quantity_measured: Optional[Union[Quantity,SimpleQuantity,Ratio,Duration]] = Field(None, description="""The quantity being measured""") + variable_measured: Optional[Variable] = Field(None, description="""The variable being measured""") + type: Literal["Measurement"] = Field("Measurement", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Specification(NamedThing): + """ + A specification of a thing + """ + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Specification"] = Field("Specification", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + +class Procedure(Specification): + """ + A canonical series of actions conducted in a certain order or manner + """ + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Procedure"] = Field("Procedure", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + +class MathematicalOperation(ConfiguredBaseModel): + """ + Application of a mathematical operation to one or more inputs to produce one or more outputs + """ + inputs: Optional[List[Any]] = Field(default_factory=list, description="""The inputs to the operation""") + outputs: Optional[List[Any]] = Field(default_factory=list, description="""The outputs of the operation""") + parts: Optional[List[MathematicalOperation]] = Field(default_factory=list, description="""The parts of the process""") + immediate_preceding_steps: Optional[List[MathematicalOperation]] = Field(default_factory=list, description="""The steps that immediately precede this step""") + + +class Collection(Intangible): + """ + A group of things. The collection may be heterogeneous or homogeneous. + """ + members: Optional[List[Union[Entity,Variable,NamedThing,Intangible,Observation,PostalAddress,Measurement,Role,Relationship,Collection,Quantity,QuantityRange,TimePointOrTemporalInterval,TemporalInterval,TimePoint,SimpleQuantity,Ratio,Duration,TemporalRelationship,Concept,InformationEntity,PhysicalDevice,Specification,Place,Event,RawMaterial,Equipment,BuiltEnvironmentFeature,Facility,BuiltSystem,Building,PlannedProcess,EngineeringProcess,MaterialCollection,MaterialProcessing,EngineeringMaterialProcessing,Landform,Procedure,EngineeringSpecification,QuantityKind,UnitConcept]]] = Field(default_factory=list, description="""The members of the collection""") + type: Literal["Collection"] = Field("Collection", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class QuantityKind(Concept): + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["QuantityKind"] = Field("QuantityKind", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + +class Quantity(Intangible): + has_quantity_kind: Optional[str] = Field(None, description="""The kind of quantity""") + type: Literal["Quantity"] = Field("Quantity", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class SimpleQuantity(Quantity): + """ + A quantity is a property that can be measured or counted + """ + value: Optional[float] = Field(None, description="""The value of the quantity""") + unit: Optional[str] = Field(None) + has_quantity_kind: Optional[str] = Field(None, description="""The kind of quantity""") + type: Literal["SimpleQuantity"] = Field("SimpleQuantity", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Ratio(Quantity): + """ + A tuple of two quantities + """ + numerator: Optional[Union[Quantity,SimpleQuantity,Ratio,Duration]] = Field(None, description="""The numerator of the ratio""") + denominator: Optional[Union[Quantity,SimpleQuantity,Ratio,Duration]] = Field(None, description="""The denominator of the ratio""") + has_quantity_kind: Optional[str] = Field(None, description="""The kind of quantity""") + type: Literal["Ratio"] = Field("Ratio", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class QuantityRange(Intangible): + """ + A quantity range is a property that can be measured or counted + """ + lower_bound: Optional[Union[Quantity,SimpleQuantity,Ratio,Duration]] = Field(None, description="""The lower bound of the range""") + upper_bound: Optional[Union[Quantity,SimpleQuantity,Ratio,Duration]] = Field(None, description="""The upper bound of the range""") + type: Literal["QuantityRange"] = Field("QuantityRange", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class UnitConversionOperation(MathematicalOperation): + """ + A unit conversion operation + """ + inputs: Optional[List[Union[Quantity,SimpleQuantity,Ratio,Duration]]] = Field(default_factory=list, description="""The input unit""") + outputs: Optional[List[Union[Quantity,SimpleQuantity,Ratio,Duration]]] = Field(default_factory=list, description="""The output unit""") + parts: Optional[List[MathematicalOperation]] = Field(default_factory=list, description="""The parts of the process""") + immediate_preceding_steps: Optional[List[MathematicalOperation]] = Field(default_factory=list, description="""The steps that immediately precede this step""") + + +class UnitConcept(Concept): + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["UnitConcept"] = Field("UnitConcept", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + +class Place(NamedThing): + """ + Entities that have a somewhat fixed, physical extension. + """ + address: Optional[PostalAddress] = Field(None) + geolocation: Optional[GeoPointLocation] = Field(None, description="""The geolocation of the place""") + bounding_coordinates: Optional[GeoBoxLocation] = Field(None, description="""The bounding coordinates of the place""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Place"] = Field("Place", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + +class Landform(Place): + """ + A natural feature of the solid surface of the Earth or other planetary body + """ + address: Optional[PostalAddress] = Field(None) + geolocation: Optional[GeoPointLocation] = Field(None, description="""The geolocation of the place""") + bounding_coordinates: Optional[GeoBoxLocation] = Field(None, description="""The bounding coordinates of the place""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Landform"] = Field("Landform", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + +class PostalAddress(Entity): + """ + Represents an Address + """ + street_address: Optional[str] = Field(None, description="""The street address""") + street_address_additional: Optional[str] = Field(None) + city: Optional[str] = Field(None, description="""The city""") + state: Optional[str] = Field(None, description="""The state""") + postal_code: Optional[str] = Field(None, description="""The postal code or zip code""") + country: Optional[str] = Field(None, description="""The country""") + type: Literal["PostalAddress"] = Field("PostalAddress", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class GeoPointLocation(PointLocation): + latitude: Optional[Decimal] = Field(None, description="""The latitude of the location""") + longitude: Optional[Decimal] = Field(None, description="""The longitude of the location""") + altitude: Optional[Decimal] = Field(None, description="""The altitude of the location""") + + +class GeoBoxLocation(Location): + west_bounding_coordinate: Optional[Decimal] = Field(None, description="""The westernmost coordinate of the location""") + east_bounding_coordinate: Optional[Decimal] = Field(None, description="""The easternmost coordinate of the location""") + north_bounding_coordinate: Optional[Decimal] = Field(None, description="""The northernmost coordinate of the location""") + south_bounding_coordinate: Optional[Decimal] = Field(None, description="""The southernmost coordinate of the location""") + + +class Event(NamedThing): + """ + A thing that happens + """ + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + happens_at: Optional[TimePoint] = Field(None) + has_interval: Optional[TemporalInterval] = Field(None) + has_duration: Optional[Duration] = Field(None) + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Event"] = Field("Event", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + +class TimePointOrTemporalInterval(Intangible): + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + type: Literal["TimePointOrTemporalInterval"] = Field("TimePointOrTemporalInterval", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class TemporalInterval(TimePointOrTemporalInterval): + """ + A period of time + """ + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + type: Literal["TemporalInterval"] = Field("TemporalInterval", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class TimePoint(TimePointOrTemporalInterval): + """ + A point in time. Can be fully specified, or specified in relative terms. + """ + year_value: Optional[int] = Field(None) + date_value: Optional[date] = Field(None) + time_value: Optional[str] = Field(None) + datetime_value: Optional[datetime ] = Field(None) + marker_event: Optional[str] = Field(None) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + type: Literal["TimePoint"] = Field("TimePoint", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Duration(Quantity): + """ + A length of time + """ + has_quantity_kind: Optional[str] = Field(None, description="""The kind of quantity""") + type: Literal["Duration"] = Field("Duration", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class TemporalRelationship(Relationship): + """ + A relationship to another time point + """ + predicate: Optional[RelativeTimeEnum] = Field(None, description="""The relationship between the two time points""") + relative_to: Optional[Union[TemporalInterval, TimePoint, str]] = Field(None) + type: Literal["TemporalRelationship"] = Field("TemporalRelationship", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class PlannedProcess(Event): + """ + A process that follows a defined procedure or plan + """ + follows_procedure: Optional[str] = Field(None) + uses_physical_device: Optional[str] = Field(None) + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + happens_at: Optional[TimePoint] = Field(None) + has_interval: Optional[TemporalInterval] = Field(None) + has_duration: Optional[Duration] = Field(None) + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["PlannedProcess"] = Field("PlannedProcess", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + +class MaterialCollection(PlannedProcess): + follows_procedure: Optional[str] = Field(None) + uses_physical_device: Optional[str] = Field(None) + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + happens_at: Optional[TimePoint] = Field(None) + has_interval: Optional[TemporalInterval] = Field(None) + has_duration: Optional[Duration] = Field(None) + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["MaterialCollection"] = Field("MaterialCollection", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + +class MaterialProcessing(PlannedProcess): + follows_procedure: Optional[str] = Field(None) + uses_physical_device: Optional[str] = Field(None) + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + happens_at: Optional[TimePoint] = Field(None) + has_interval: Optional[TemporalInterval] = Field(None) + has_duration: Optional[Duration] = Field(None) + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["MaterialProcessing"] = Field("MaterialProcessing", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + +class EngineeringSpecification(Procedure): + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["EngineeringSpecification"] = Field("EngineeringSpecification", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + +class RawMaterial(NamedThing): + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["RawMaterial"] = Field("RawMaterial", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + +class EngineeringProcess(Event): + follows_procedure: Optional[str] = Field(None) + part_of: Optional[str] = Field(None) + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + happens_at: Optional[TimePoint] = Field(None) + has_interval: Optional[TemporalInterval] = Field(None) + has_duration: Optional[Duration] = Field(None) + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["EngineeringProcess"] = Field("EngineeringProcess", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + +class EngineeringMaterialProcessing(MaterialProcessing): + follows_procedure: Optional[str] = Field(None) + uses_physical_device: Optional[str] = Field(None) + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + happens_at: Optional[TimePoint] = Field(None) + has_interval: Optional[TemporalInterval] = Field(None) + has_duration: Optional[Duration] = Field(None) + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["EngineeringMaterialProcessing"] = Field("EngineeringMaterialProcessing", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + +class Equipment(NamedThing): + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Equipment"] = Field("Equipment", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + +class BuiltEnvironmentFeature(NamedThing): + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["BuiltEnvironmentFeature"] = Field("BuiltEnvironmentFeature", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + +class Facility(BuiltEnvironmentFeature): + located_at_place: Optional[str] = Field(None, description="""The place where the entity is located""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Facility"] = Field("Facility", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + +class Building(Facility): + located_at_place: Optional[str] = Field(None, description="""The place where the entity is located""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Building"] = Field("Building", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + +class BuiltSystem(BuiltEnvironmentFeature): + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["BuiltSystem"] = Field("BuiltSystem", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + +# Update forward refs +# see https://pydantic-docs.helpmanual.io/usage/postponed_annotations/ +Entity.update_forward_refs() +Variable.update_forward_refs() +NamedThing.update_forward_refs() +Concept.update_forward_refs() +InformationEntity.update_forward_refs() +PhysicalDevice.update_forward_refs() +Intangible.update_forward_refs() +Role.update_forward_refs() +Relationship.update_forward_refs() +Location.update_forward_refs() +PointLocation.update_forward_refs() +Observation.update_forward_refs() +Measurement.update_forward_refs() +Specification.update_forward_refs() +Procedure.update_forward_refs() +MathematicalOperation.update_forward_refs() +Collection.update_forward_refs() +QuantityKind.update_forward_refs() +Quantity.update_forward_refs() +SimpleQuantity.update_forward_refs() +Ratio.update_forward_refs() +QuantityRange.update_forward_refs() +UnitConversionOperation.update_forward_refs() +UnitConcept.update_forward_refs() +Place.update_forward_refs() +Landform.update_forward_refs() +PostalAddress.update_forward_refs() +GeoPointLocation.update_forward_refs() +GeoBoxLocation.update_forward_refs() +Event.update_forward_refs() +TimePointOrTemporalInterval.update_forward_refs() +TemporalInterval.update_forward_refs() +TimePoint.update_forward_refs() +Duration.update_forward_refs() +TemporalRelationship.update_forward_refs() +PlannedProcess.update_forward_refs() +MaterialCollection.update_forward_refs() +MaterialProcessing.update_forward_refs() +EngineeringSpecification.update_forward_refs() +RawMaterial.update_forward_refs() +EngineeringProcess.update_forward_refs() +EngineeringMaterialProcessing.update_forward_refs() +Equipment.update_forward_refs() +BuiltEnvironmentFeature.update_forward_refs() +Facility.update_forward_refs() +Building.update_forward_refs() +BuiltSystem.update_forward_refs() + diff --git a/src/linkml_common/datamodel/clinicalresearch.py b/src/linkml_common/datamodel/clinicalresearch.py new file mode 100644 index 0000000..ff18e3c --- /dev/null +++ b/src/linkml_common/datamodel/clinicalresearch.py @@ -0,0 +1,877 @@ +from __future__ import annotations +from datetime import ( + datetime, + date +) +from decimal import Decimal +from enum import Enum +import re +import sys +from typing import ( + Any, + List, + Literal, + Dict, + Optional, + Union +) +from pydantic.version import VERSION as PYDANTIC_VERSION +if int(PYDANTIC_VERSION[0])>=2: + from pydantic import ( + BaseModel, + ConfigDict, + Field, + field_validator + ) +else: + from pydantic import ( + BaseModel, + Field, + validator + ) + +metamodel_version = "None" +version = "None" + + +class WeakRefShimBaseModel(BaseModel): + __slots__ = '__weakref__' + +class ConfiguredBaseModel(WeakRefShimBaseModel, + validate_assignment = True, + validate_all = True, + underscore_attrs_are_private = True, + extra = "forbid", + arbitrary_types_allowed = True, + use_enum_values = True): + pass + + +class RelativeTimeEnum(str, Enum): + BEFORE = "BEFORE" + AFTER = "AFTER" + AT_SAME_TIME_AS = "AT_SAME_TIME_AS" + + +class HumanLanguageCodeEnum(str): + """ + An enumeration of languages + """ + pass + + +class PersonStatus(str, Enum): + # the person is living + ALIVE = "ALIVE" + # the person is deceased + DEAD = "DEAD" + # the vital status is not known + UNKNOWN = "UNKNOWN" + + +class HealthcareEncounterClassification(str, Enum): + # Person visiting hospital, at a Care Site, in bed, for duration of more than one day, with physicians and other Providers permanently available to deliver service around the clock + Inpatient_Visit = "Inpatient Visit" + # Person visiting dedicated healthcare institution for treating emergencies, at a Care Site, within one day, with physicians and Providers permanently available to deliver service around the clock + Emergency_Room_Visit = "Emergency Room Visit" + # Person visiting ER followed by a subsequent Inpatient Visit, where Emergency department is part of hospital, and transition from the ER to other hospital departments is undefined + Emergency_Room_and_Inpatient_Visit = "Emergency Room and Inpatient Visit" + # Person visiting dedicated institution for reasons of poor health, at a Care Site, long-term or permanently, with no physician but possibly other Providers permanently available to deliver service around the clock + Non_hospital_institution_Visit = "Non-hospital institution Visit" + # Person visiting dedicated ambulatory healthcare institution, at a Care Site, within one day, without bed, with physicians or medical Providers delivering service during Visit + Outpatient_Visit = "Outpatient Visit" + # Provider visiting Person, without a Care Site, within one day, delivering service + Home_Visit = "Home Visit" + # Patient engages with Provider through communication media + Telehealth_Visit = "Telehealth Visit" + # Person visiting pharmacy for dispensing of Drug, at a Care Site, within one day + Pharmacy_Visit = "Pharmacy Visit" + # Patient visiting dedicated institution, at a Care Site, within one day, for the purpose of a Measurement. + Laboratory_Visit = "Laboratory Visit" + # Person using transportation service for the purpose of initiating one of the other Visits, without a Care Site, within one day, potentially with Providers accompanying the Visit and delivering service + Ambulance_Visit = "Ambulance Visit" + # Person interacting with healthcare system, without a Care Site, within a day, with no Providers involved, for administrative purposes + Case_Management_Visit = "Case Management Visit" + + +class CaseOrControlEnum(str, Enum): + case_role_in_case_control_study = "CASE" + control_role_in_case_control_study = "CONTROL" + + +class StudyDesignEnum(str): + pass + + +class InvestigativeProtocolEnum(str): + pass + + +class SampleProcessingEnum(str): + pass + + +class Identified(ConfiguredBaseModel): + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + + +class Typed(ConfiguredBaseModel): + type: Literal["Typed"] = Field("Typed", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Entity(Typed): + """ + A physical, digital, conceptual, or other kind of thing with some common characteristics + """ + type: Literal["Entity"] = Field("Entity", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Intangible(Entity): + """ + An entity that is not a physical object, process, or information + """ + type: Literal["Intangible"] = Field("Intangible", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class NamedThing(Entity, Identified): + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["NamedThing"] = Field("NamedThing", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Concept(Intangible, Identified): + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Concept"] = Field("Concept", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class InformationEntity(Intangible, Identified): + """ + An entity that describes some information + """ + describes: Optional[Any] = Field(None, description="""The thing that is being described""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["InformationEntity"] = Field("InformationEntity", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class PhysicalDevice(NamedThing): + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["PhysicalDevice"] = Field("PhysicalDevice", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class StructuredValue(Intangible): + """ + A value that is a structured collection of other values + """ + type: Literal["StructuredValue"] = Field("StructuredValue", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Role(Intangible): + type: Literal["Role"] = Field("Role", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Relationship(Intangible): + type: Literal["Relationship"] = Field("Relationship", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Location(StructuredValue): + type: Literal["Location"] = Field("Location", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class PointLocation(Location): + type: Literal["PointLocation"] = Field("PointLocation", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Specification(InformationEntity): + """ + A specification of a thing + """ + describes: Optional[Any] = Field(None, description="""The thing that is being described""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Specification"] = Field("Specification", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Procedure(Specification): + """ + A canonical series of actions conducted in a certain order or manner + """ + describes: Optional[Any] = Field(None, description="""The thing that is being described""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Procedure"] = Field("Procedure", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class EntitySet(Intangible): + """ + A group of things. The collection may be heterogeneous or homogeneous. + """ + members: Optional[List[Union[Entity,Intangible,NamedThing,Event,Variable,LifeEvent,HealthcareEncounter,HealthcareConditionOccurrence,ExecutionOfProcedure,Observation,Investigation,ClinicalCohortEnrollment,Measurement,PlannedProcess,MathematicalOperationExecution,MaterialCollection,MaterialProcessing,InvestigativeProcess,SampleCollectionProcess,DataGenerationFromSample,SampleProcessing,PhysicalDevice,Place,Agent,CreativeWork,SampleMaterial,ClinicalCohort,Person,Organization,AutomatedAgent,HealthcareOrganization,Landform,HealthcareSite,Concept,InformationEntity,StructuredValue,Role,Relationship,EntitySet,Quantity,QuantityRange,TimePointOrTemporalInterval,Service,TemporalInterval,TimePoint,SimpleQuantity,Ratio,Duration,TemporalRelationship,HealthcareRole,HealthcareProvider,Patient,Location,PostalAddress,PointLocation,GeoBoxLocation,GeoPointLocation,Specification,ClinicalCohortDefinition,Procedure,InvestigativeProtocol,StudyDesign,QuantityKind,UnitConcept]]] = Field(default_factory=list, description="""The members of the collection""") + type: Literal["EntitySet"] = Field("EntitySet", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class QuantityKind(Concept): + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["QuantityKind"] = Field("QuantityKind", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Quantity(Intangible): + has_quantity_kind: Optional[str] = Field(None, description="""The kind of quantity""") + type: Literal["Quantity"] = Field("Quantity", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class SimpleQuantity(Quantity): + """ + A quantity is a property that can be measured or counted + """ + value: Optional[float] = Field(None, description="""The value of the quantity""") + unit: Optional[str] = Field(None) + has_quantity_kind: Optional[str] = Field(None, description="""The kind of quantity""") + type: Literal["SimpleQuantity"] = Field("SimpleQuantity", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Ratio(Quantity): + """ + A tuple of two quantities + """ + numerator: Optional[Union[Quantity,SimpleQuantity,Ratio,Duration]] = Field(None, description="""The numerator of the ratio""") + denominator: Optional[Union[Quantity,SimpleQuantity,Ratio,Duration]] = Field(None, description="""The denominator of the ratio""") + has_quantity_kind: Optional[str] = Field(None, description="""The kind of quantity""") + type: Literal["Ratio"] = Field("Ratio", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class QuantityRange(Intangible): + """ + A quantity range is a property that can be measured or counted + """ + lower_bound: Optional[Union[Quantity,SimpleQuantity,Ratio,Duration]] = Field(None, description="""The lower bound of the range""") + upper_bound: Optional[Union[Quantity,SimpleQuantity,Ratio,Duration]] = Field(None, description="""The upper bound of the range""") + type: Literal["QuantityRange"] = Field("QuantityRange", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class UnitConcept(Concept): + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["UnitConcept"] = Field("UnitConcept", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Place(NamedThing): + """ + Entities that have a somewhat fixed, physical extension. + """ + address: Optional[PostalAddress] = Field(None) + geolocation: Optional[GeoPointLocation] = Field(None, description="""The geolocation of the place""") + bounding_coordinates: Optional[GeoBoxLocation] = Field(None, description="""The bounding coordinates of the place""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Place"] = Field("Place", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Landform(Place): + """ + A natural feature of the solid surface of the Earth or other planetary body + """ + address: Optional[PostalAddress] = Field(None) + geolocation: Optional[GeoPointLocation] = Field(None, description="""The geolocation of the place""") + bounding_coordinates: Optional[GeoBoxLocation] = Field(None, description="""The bounding coordinates of the place""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Landform"] = Field("Landform", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class PostalAddress(StructuredValue): + """ + Represents an Address + """ + street_address: Optional[str] = Field(None, description="""The street address""") + street_address_additional: Optional[str] = Field(None) + city: Optional[str] = Field(None, description="""The city""") + state: Optional[str] = Field(None, description="""The state""") + postal_code: Optional[str] = Field(None, description="""The postal code or zip code""") + country: Optional[str] = Field(None, description="""The country""") + type: Literal["PostalAddress"] = Field("PostalAddress", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class GeoPointLocation(PointLocation): + latitude: Optional[Decimal] = Field(None, description="""The latitude of the location""") + longitude: Optional[Decimal] = Field(None, description="""The longitude of the location""") + altitude: Optional[Decimal] = Field(None, description="""The altitude of the location""") + type: Literal["GeoPointLocation"] = Field("GeoPointLocation", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class GeoBoxLocation(Location): + west_bounding_coordinate: Optional[Decimal] = Field(None, description="""The westernmost coordinate of the location""") + east_bounding_coordinate: Optional[Decimal] = Field(None, description="""The easternmost coordinate of the location""") + north_bounding_coordinate: Optional[Decimal] = Field(None, description="""The northernmost coordinate of the location""") + south_bounding_coordinate: Optional[Decimal] = Field(None, description="""The southernmost coordinate of the location""") + type: Literal["GeoBoxLocation"] = Field("GeoBoxLocation", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Event(Entity, Identified): + """ + A thing that happens + """ + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + happens_at: Optional[TimePoint] = Field(None) + has_interval: Optional[TemporalInterval] = Field(None) + has_duration: Optional[Duration] = Field(None) + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Event"] = Field("Event", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class TimePointOrTemporalInterval(Intangible): + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + type: Literal["TimePointOrTemporalInterval"] = Field("TimePointOrTemporalInterval", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class TemporalInterval(TimePointOrTemporalInterval): + """ + A period of time + """ + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + type: Literal["TemporalInterval"] = Field("TemporalInterval", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class TimePoint(TimePointOrTemporalInterval): + """ + A point in time. Can be fully specified, or specified in relative terms. + """ + year_value: Optional[int] = Field(None) + date_value: Optional[date] = Field(None) + time_value: Optional[str] = Field(None) + datetime_value: Optional[datetime ] = Field(None) + marker_event: Optional[str] = Field(None) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + type: Literal["TimePoint"] = Field("TimePoint", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Duration(Quantity): + """ + A length of time + """ + has_quantity_kind: Optional[str] = Field(None, description="""The kind of quantity""") + type: Literal["Duration"] = Field("Duration", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class TemporalRelationship(Relationship): + """ + A relationship to another time point + """ + predicate: Optional[RelativeTimeEnum] = Field(None, description="""The relationship between the two time points""") + relative_to: Optional[Union[TemporalInterval, TimePoint, str]] = Field(None) + type: Literal["TemporalRelationship"] = Field("TemporalRelationship", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Agent(NamedThing): + """ + Represents an Agent + """ + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Agent"] = Field("Agent", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Person(Agent): + """ + Represents a Person + """ + primary_email: Optional[str] = Field(None, description="""The main email address of a person""") + birth_date: Optional[date] = Field(None, description="""Date on which a person is born""") + age_in_years: Optional[int] = Field(None, description="""Number of years since birth""") + vital_status: Optional[PersonStatus] = Field(None, description="""living or dead status""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Person"] = Field("Person", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + @validator('primary_email', allow_reuse=True) + def pattern_primary_email(cls, v): + pattern=re.compile(r"^\S+@[\S+\.]+\S+") + if isinstance(v,list): + for element in v: + if not pattern.match(element): + raise ValueError(f"Invalid primary_email format: {element}") + elif isinstance(v,str): + if not pattern.match(v): + raise ValueError(f"Invalid primary_email format: {v}") + return v + + +class Organization(Agent): + """ + Represents an Organization + """ + provides_services: Optional[List[Service]] = Field(default_factory=list) + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Organization"] = Field("Organization", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class AutomatedAgent(Agent): + """ + Represents an Automated Agent + """ + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["AutomatedAgent"] = Field("AutomatedAgent", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class LifeEvent(Event): + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + happens_at: Optional[TimePoint] = Field(None) + has_interval: Optional[TemporalInterval] = Field(None) + has_duration: Optional[Duration] = Field(None) + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["LifeEvent"] = Field("LifeEvent", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class CreationMetadata(ConfiguredBaseModel): + title: Optional[str] = Field(None, description="""The title of the item""") + abstract: Optional[str] = Field(None, description="""A summary of the item""") + rights: Optional[str] = Field(None, description="""Information about rights held in and over the item""") + creators: Optional[List[str]] = Field(default_factory=list, description="""The person or organization who created the work""") + contributors: Optional[List[str]] = Field(default_factory=list, description="""A person or organization that contributed to the creation of the work""") + contacts: Optional[List[str]] = Field(default_factory=list, description="""A contact point for a person or organization""") + keywords: Optional[List[str]] = Field(default_factory=list, description="""Keywords or tags used to describe this item""") + + +class CreativeWork(CreationMetadata, NamedThing): + """ + The most generic kind of creative work, including books, movies, photographs, software programs, etc. + """ + title: Optional[str] = Field(None, description="""The title of the item""") + abstract: Optional[str] = Field(None, description="""A summary of the item""") + rights: Optional[str] = Field(None, description="""Information about rights held in and over the item""") + creators: Optional[List[str]] = Field(default_factory=list, description="""The person or organization who created the work""") + contributors: Optional[List[str]] = Field(default_factory=list, description="""A person or organization that contributed to the creation of the work""") + contacts: Optional[List[str]] = Field(default_factory=list, description="""A contact point for a person or organization""") + keywords: Optional[List[str]] = Field(default_factory=list, description="""Keywords or tags used to describe this item""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["CreativeWork"] = Field("CreativeWork", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Service(Intangible): + """ + A service provided by an organization + """ + type: Literal["Service"] = Field("Service", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class HealthcareSite(Place): + address: Optional[PostalAddress] = Field(None) + geolocation: Optional[GeoPointLocation] = Field(None, description="""The geolocation of the place""") + bounding_coordinates: Optional[GeoBoxLocation] = Field(None, description="""The bounding coordinates of the place""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["HealthcareSite"] = Field("HealthcareSite", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class HealthcareEncounter(Event): + """ + An interaction between a patient and one or more healthcare providers + """ + patient: Optional[Patient] = Field(None) + provider: Optional[HealthcareProvider] = Field(None) + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + happens_at: Optional[TimePoint] = Field(None) + has_interval: Optional[TemporalInterval] = Field(None) + has_duration: Optional[Duration] = Field(None) + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["HealthcareEncounter"] = Field("HealthcareEncounter", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class HealthcareOrganization(Organization): + """ + An organization that provides healthcare services + """ + provides_services: Optional[List[Service]] = Field(default_factory=list) + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["HealthcareOrganization"] = Field("HealthcareOrganization", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class HealthcareRole(Role): + is_person: Optional[str] = Field(None) + type: Literal["HealthcareRole"] = Field("HealthcareRole", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class HealthcareProvider(HealthcareRole): + speciality: Optional[str] = Field(None) + care_site: Optional[str] = Field(None) + is_person: Optional[str] = Field(None) + type: Literal["HealthcareProvider"] = Field("HealthcareProvider", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class HealthcareConditionOccurrence(Event): + patient: Optional[Patient] = Field(None) + observed_during: Optional[str] = Field(None) + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + happens_at: Optional[TimePoint] = Field(None) + has_interval: Optional[TemporalInterval] = Field(None) + has_duration: Optional[Duration] = Field(None) + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["HealthcareConditionOccurrence"] = Field("HealthcareConditionOccurrence", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Patient(HealthcareRole): + is_person: Optional[str] = Field(None) + type: Literal["Patient"] = Field("Patient", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Variable(Entity): + allowed_units: Optional[List[str]] = Field(default_factory=list, description="""The units that are allowed for this variable""") + type: Literal["Variable"] = Field("Variable", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class ExecutionOfProcedure(Event): + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + happens_at: Optional[TimePoint] = Field(None) + has_interval: Optional[TemporalInterval] = Field(None) + has_duration: Optional[Duration] = Field(None) + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["ExecutionOfProcedure"] = Field("ExecutionOfProcedure", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class PlannedProcess(ExecutionOfProcedure): + """ + A process that follows a defined procedure or plan + """ + follows_procedure: Optional[str] = Field(None) + uses_physical_device: Optional[str] = Field(None) + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + happens_at: Optional[TimePoint] = Field(None) + has_interval: Optional[TemporalInterval] = Field(None) + has_duration: Optional[Duration] = Field(None) + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["PlannedProcess"] = Field("PlannedProcess", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class MathematicalOperationExecution(PlannedProcess): + """ + Application of a mathematical operation to one or more inputs to produce one or more outputs + """ + inputs: Optional[List[Any]] = Field(default_factory=list, description="""The inputs to the operation""") + outputs: Optional[List[Any]] = Field(default_factory=list, description="""The outputs of the operation""") + parts: Optional[List[str]] = Field(default_factory=list, description="""The parts of the process""") + immediate_preceding_steps: Optional[List[str]] = Field(default_factory=list, description="""The steps that immediately precede this step""") + follows_procedure: Optional[str] = Field(None) + uses_physical_device: Optional[str] = Field(None) + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + happens_at: Optional[TimePoint] = Field(None) + has_interval: Optional[TemporalInterval] = Field(None) + has_duration: Optional[Duration] = Field(None) + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["MathematicalOperationExecution"] = Field("MathematicalOperationExecution", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class MaterialCollection(PlannedProcess): + follows_procedure: Optional[str] = Field(None) + uses_physical_device: Optional[str] = Field(None) + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + happens_at: Optional[TimePoint] = Field(None) + has_interval: Optional[TemporalInterval] = Field(None) + has_duration: Optional[Duration] = Field(None) + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["MaterialCollection"] = Field("MaterialCollection", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class MaterialProcessing(PlannedProcess): + follows_procedure: Optional[str] = Field(None) + uses_physical_device: Optional[str] = Field(None) + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + happens_at: Optional[TimePoint] = Field(None) + has_interval: Optional[TemporalInterval] = Field(None) + has_duration: Optional[Duration] = Field(None) + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["MaterialProcessing"] = Field("MaterialProcessing", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Observation(Event): + """ + A statement about the state of something + """ + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + happens_at: Optional[TimePoint] = Field(None) + has_interval: Optional[TemporalInterval] = Field(None) + has_duration: Optional[Duration] = Field(None) + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Observation"] = Field("Observation", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Measurement(Observation): + quantity_measured: Optional[Union[Quantity,SimpleQuantity,Ratio,Duration]] = Field(None, description="""The quantity being measured""") + variable_measured: Optional[Variable] = Field(None, description="""The variable being measured""") + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + happens_at: Optional[TimePoint] = Field(None) + has_interval: Optional[TemporalInterval] = Field(None) + has_duration: Optional[Duration] = Field(None) + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Measurement"] = Field("Measurement", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Investigation(Event): + objectives: Optional[str] = Field(None) + variables: Optional[List[Variable]] = Field(default_factory=list) + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + happens_at: Optional[TimePoint] = Field(None) + has_interval: Optional[TemporalInterval] = Field(None) + has_duration: Optional[Duration] = Field(None) + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Investigation"] = Field("Investigation", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class InvestigativeProtocol(Procedure): + protocols_io_url: Optional[str] = Field(None) + describes: Optional[Any] = Field(None, description="""The thing that is being described""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["InvestigativeProtocol"] = Field("InvestigativeProtocol", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class StudyDesign(Procedure): + describes: Optional[Any] = Field(None, description="""The thing that is being described""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["StudyDesign"] = Field("StudyDesign", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class SampleMaterial(NamedThing): + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["SampleMaterial"] = Field("SampleMaterial", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class InvestigativeProcess(PlannedProcess): + follows_procedure: Optional[str] = Field(None) + part_of: Optional[str] = Field(None) + uses_physical_device: Optional[str] = Field(None) + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + happens_at: Optional[TimePoint] = Field(None) + has_interval: Optional[TemporalInterval] = Field(None) + has_duration: Optional[Duration] = Field(None) + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["InvestigativeProcess"] = Field("InvestigativeProcess", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class SampleCollectionProcess(InvestigativeProcess): + material_collected: Optional[str] = Field(None) + collected_from: Optional[str] = Field(None) + follows_procedure: Optional[str] = Field(None) + part_of: Optional[str] = Field(None) + uses_physical_device: Optional[str] = Field(None) + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + happens_at: Optional[TimePoint] = Field(None) + has_interval: Optional[TemporalInterval] = Field(None) + has_duration: Optional[Duration] = Field(None) + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["SampleCollectionProcess"] = Field("SampleCollectionProcess", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class SampleProcessing(MaterialProcessing): + follows_procedure: Optional[str] = Field(None) + uses_physical_device: Optional[str] = Field(None) + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + happens_at: Optional[TimePoint] = Field(None) + has_interval: Optional[TemporalInterval] = Field(None) + has_duration: Optional[Duration] = Field(None) + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["SampleProcessing"] = Field("SampleProcessing", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class DataGenerationFromSample(InvestigativeProcess): + follows_procedure: Optional[str] = Field(None) + part_of: Optional[str] = Field(None) + uses_physical_device: Optional[str] = Field(None) + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + happens_at: Optional[TimePoint] = Field(None) + has_interval: Optional[TemporalInterval] = Field(None) + has_duration: Optional[Duration] = Field(None) + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["DataGenerationFromSample"] = Field("DataGenerationFromSample", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class ClinicalCohort(NamedThing): + """ + A group of patients who share a common set of characteristics + """ + definition: Optional[str] = Field(None) + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["ClinicalCohort"] = Field("ClinicalCohort", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class ClinicalCohortDefinition(InformationEntity): + """ + A definition of a clinical cohort + """ + describes: Optional[Any] = Field(None, description="""The thing that is being described""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["ClinicalCohortDefinition"] = Field("ClinicalCohortDefinition", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class ClinicalCohortEnrollment(Event): + """ + An event relating a patient to a clinical cohort + """ + patient: Optional[Patient] = Field(None) + cohort: Optional[str] = Field(None) + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + happens_at: Optional[TimePoint] = Field(None) + has_interval: Optional[TemporalInterval] = Field(None) + has_duration: Optional[Duration] = Field(None) + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["ClinicalCohortEnrollment"] = Field("ClinicalCohortEnrollment", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +# Update forward refs +# see https://pydantic-docs.helpmanual.io/usage/postponed_annotations/ +Identified.update_forward_refs() +Typed.update_forward_refs() +Entity.update_forward_refs() +Intangible.update_forward_refs() +NamedThing.update_forward_refs() +Concept.update_forward_refs() +InformationEntity.update_forward_refs() +PhysicalDevice.update_forward_refs() +StructuredValue.update_forward_refs() +Role.update_forward_refs() +Relationship.update_forward_refs() +Location.update_forward_refs() +PointLocation.update_forward_refs() +Specification.update_forward_refs() +Procedure.update_forward_refs() +EntitySet.update_forward_refs() +QuantityKind.update_forward_refs() +Quantity.update_forward_refs() +SimpleQuantity.update_forward_refs() +Ratio.update_forward_refs() +QuantityRange.update_forward_refs() +UnitConcept.update_forward_refs() +Place.update_forward_refs() +Landform.update_forward_refs() +PostalAddress.update_forward_refs() +GeoPointLocation.update_forward_refs() +GeoBoxLocation.update_forward_refs() +Event.update_forward_refs() +TimePointOrTemporalInterval.update_forward_refs() +TemporalInterval.update_forward_refs() +TimePoint.update_forward_refs() +Duration.update_forward_refs() +TemporalRelationship.update_forward_refs() +Agent.update_forward_refs() +Person.update_forward_refs() +Organization.update_forward_refs() +AutomatedAgent.update_forward_refs() +LifeEvent.update_forward_refs() +CreationMetadata.update_forward_refs() +CreativeWork.update_forward_refs() +Service.update_forward_refs() +HealthcareSite.update_forward_refs() +HealthcareEncounter.update_forward_refs() +HealthcareOrganization.update_forward_refs() +HealthcareRole.update_forward_refs() +HealthcareProvider.update_forward_refs() +HealthcareConditionOccurrence.update_forward_refs() +Patient.update_forward_refs() +Variable.update_forward_refs() +ExecutionOfProcedure.update_forward_refs() +PlannedProcess.update_forward_refs() +MathematicalOperationExecution.update_forward_refs() +MaterialCollection.update_forward_refs() +MaterialProcessing.update_forward_refs() +Observation.update_forward_refs() +Measurement.update_forward_refs() +Investigation.update_forward_refs() +InvestigativeProtocol.update_forward_refs() +StudyDesign.update_forward_refs() +SampleMaterial.update_forward_refs() +InvestigativeProcess.update_forward_refs() +SampleCollectionProcess.update_forward_refs() +SampleProcessing.update_forward_refs() +DataGenerationFromSample.update_forward_refs() +ClinicalCohort.update_forward_refs() +ClinicalCohortDefinition.update_forward_refs() +ClinicalCohortEnrollment.update_forward_refs() + diff --git a/src/linkml_common/datamodel/computational.py b/src/linkml_common/datamodel/computational.py new file mode 100644 index 0000000..9131afc --- /dev/null +++ b/src/linkml_common/datamodel/computational.py @@ -0,0 +1,191 @@ +from __future__ import annotations +from datetime import ( + datetime, + date +) +from decimal import Decimal +from enum import Enum +import re +import sys +from typing import ( + Any, + List, + Literal, + Dict, + Optional, + Union +) +from pydantic.version import VERSION as PYDANTIC_VERSION +if int(PYDANTIC_VERSION[0])>=2: + from pydantic import ( + BaseModel, + ConfigDict, + Field, + field_validator + ) +else: + from pydantic import ( + BaseModel, + Field, + validator + ) + +metamodel_version = "None" +version = "None" + + +class WeakRefShimBaseModel(BaseModel): + __slots__ = '__weakref__' + +class ConfiguredBaseModel(WeakRefShimBaseModel, + validate_assignment = True, + validate_all = True, + underscore_attrs_are_private = True, + extra = "forbid", + arbitrary_types_allowed = True, + use_enum_values = True): + pass + + +class Entity(ConfiguredBaseModel): + """ + A physical, digital, conceptual, or other kind of thing with some common characteristics + """ + type: Literal["Entity"] = Field("Entity", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class NamedThing(Entity): + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["NamedThing"] = Field("NamedThing", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + +class Concept(NamedThing): + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Concept"] = Field("Concept", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + +class InformationEntity(NamedThing): + """ + An entity that describes some information + """ + describes: Optional[Any] = Field(None, description="""The thing that is being described""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["InformationEntity"] = Field("InformationEntity", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + +class PhysicalDevice(NamedThing): + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["PhysicalDevice"] = Field("PhysicalDevice", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + +class Intangible(Entity): + """ + An entity that is not a physical object, process, or information + """ + type: Literal["Intangible"] = Field("Intangible", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Role(Intangible): + type: Literal["Role"] = Field("Role", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Relationship(Intangible): + type: Literal["Relationship"] = Field("Relationship", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Location(ConfiguredBaseModel): + pass + + +class PointLocation(Location): + pass + + +class Observation(Entity): + """ + A statement about the state of something + """ + type: Literal["Observation"] = Field("Observation", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Specification(NamedThing): + """ + A specification of a thing + """ + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Specification"] = Field("Specification", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + +class Procedure(Specification): + """ + A canonical series of actions conducted in a certain order or manner + """ + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Procedure"] = Field("Procedure", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + +class MathematicalOperation(ConfiguredBaseModel): + """ + Application of a mathematical operation to one or more inputs to produce one or more outputs + """ + inputs: Optional[List[Any]] = Field(default_factory=list, description="""The inputs to the operation""") + outputs: Optional[List[Any]] = Field(default_factory=list, description="""The outputs of the operation""") + parts: Optional[List[MathematicalOperation]] = Field(default_factory=list, description="""The parts of the process""") + immediate_preceding_steps: Optional[List[MathematicalOperation]] = Field(default_factory=list, description="""The steps that immediately precede this step""") + + +class Collection(Intangible): + """ + A group of things. The collection may be heterogeneous or homogeneous. + """ + members: Optional[List[Union[Entity,NamedThing,Intangible,Observation,Role,Relationship,Collection,DataStructure,Concept,InformationEntity,PhysicalDevice,Specification,Procedure]]] = Field(default_factory=list, description="""The members of the collection""") + type: Literal["Collection"] = Field("Collection", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class DataStructure(Intangible): + type: Literal["DataStructure"] = Field("DataStructure", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +# Update forward refs +# see https://pydantic-docs.helpmanual.io/usage/postponed_annotations/ +Entity.update_forward_refs() +NamedThing.update_forward_refs() +Concept.update_forward_refs() +InformationEntity.update_forward_refs() +PhysicalDevice.update_forward_refs() +Intangible.update_forward_refs() +Role.update_forward_refs() +Relationship.update_forward_refs() +Location.update_forward_refs() +PointLocation.update_forward_refs() +Observation.update_forward_refs() +Specification.update_forward_refs() +Procedure.update_forward_refs() +MathematicalOperation.update_forward_refs() +Collection.update_forward_refs() +DataStructure.update_forward_refs() + diff --git a/src/linkml_common/datamodel/core.py b/src/linkml_common/datamodel/core.py new file mode 100644 index 0000000..4eb6596 --- /dev/null +++ b/src/linkml_common/datamodel/core.py @@ -0,0 +1,176 @@ +from __future__ import annotations +from datetime import ( + datetime, + date +) +from decimal import Decimal +from enum import Enum +import re +import sys +from typing import ( + Any, + List, + Literal, + Dict, + Optional, + Union +) +from pydantic.version import VERSION as PYDANTIC_VERSION +if int(PYDANTIC_VERSION[0])>=2: + from pydantic import ( + BaseModel, + ConfigDict, + Field, + field_validator + ) +else: + from pydantic import ( + BaseModel, + Field, + validator + ) + +metamodel_version = "None" +version = "None" + + +class WeakRefShimBaseModel(BaseModel): + __slots__ = '__weakref__' + +class ConfiguredBaseModel(WeakRefShimBaseModel, + validate_assignment = True, + validate_all = True, + underscore_attrs_are_private = True, + extra = "forbid", + arbitrary_types_allowed = True, + use_enum_values = True): + pass + + +class Identified(ConfiguredBaseModel): + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + + +class Typed(ConfiguredBaseModel): + type: Literal["Typed"] = Field("Typed", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Entity(Typed): + """ + A physical, digital, conceptual, or other kind of thing with some common characteristics + """ + type: Literal["Entity"] = Field("Entity", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Intangible(Entity): + """ + An entity that is not a physical object, process, or information + """ + type: Literal["Intangible"] = Field("Intangible", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class NamedThing(Entity, Identified): + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["NamedThing"] = Field("NamedThing", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Concept(Intangible, Identified): + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Concept"] = Field("Concept", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class InformationEntity(Intangible, Identified): + """ + An entity that describes some information + """ + describes: Optional[Any] = Field(None, description="""The thing that is being described""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["InformationEntity"] = Field("InformationEntity", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class PhysicalDevice(NamedThing): + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["PhysicalDevice"] = Field("PhysicalDevice", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class StructuredValue(Intangible): + """ + A value that is a structured collection of other values + """ + type: Literal["StructuredValue"] = Field("StructuredValue", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Role(Intangible): + type: Literal["Role"] = Field("Role", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Relationship(Intangible): + type: Literal["Relationship"] = Field("Relationship", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Location(StructuredValue): + type: Literal["Location"] = Field("Location", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class PointLocation(Location): + type: Literal["PointLocation"] = Field("PointLocation", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Specification(InformationEntity): + """ + A specification of a thing + """ + describes: Optional[Any] = Field(None, description="""The thing that is being described""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Specification"] = Field("Specification", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Procedure(Specification): + """ + A canonical series of actions conducted in a certain order or manner + """ + describes: Optional[Any] = Field(None, description="""The thing that is being described""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Procedure"] = Field("Procedure", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class EntitySet(Intangible): + """ + A group of things. The collection may be heterogeneous or homogeneous. + """ + members: Optional[List[Union[Entity,Intangible,NamedThing,PhysicalDevice,Concept,InformationEntity,StructuredValue,Role,Relationship,EntitySet,Location,PointLocation,Specification,Procedure]]] = Field(default_factory=list, description="""The members of the collection""") + type: Literal["EntitySet"] = Field("EntitySet", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +# Update forward refs +# see https://pydantic-docs.helpmanual.io/usage/postponed_annotations/ +Identified.update_forward_refs() +Typed.update_forward_refs() +Entity.update_forward_refs() +Intangible.update_forward_refs() +NamedThing.update_forward_refs() +Concept.update_forward_refs() +InformationEntity.update_forward_refs() +PhysicalDevice.update_forward_refs() +StructuredValue.update_forward_refs() +Role.update_forward_refs() +Relationship.update_forward_refs() +Location.update_forward_refs() +PointLocation.update_forward_refs() +Specification.update_forward_refs() +Procedure.update_forward_refs() +EntitySet.update_forward_refs() + diff --git a/src/linkml_common/datamodel/datasets.py b/src/linkml_common/datamodel/datasets.py new file mode 100644 index 0000000..3781444 --- /dev/null +++ b/src/linkml_common/datamodel/datasets.py @@ -0,0 +1,693 @@ +from __future__ import annotations +from datetime import ( + datetime, + date +) +from decimal import Decimal +from enum import Enum +import re +import sys +from typing import ( + Any, + List, + Literal, + Dict, + Optional, + Union +) +from pydantic.version import VERSION as PYDANTIC_VERSION +if int(PYDANTIC_VERSION[0])>=2: + from pydantic import ( + BaseModel, + ConfigDict, + Field, + field_validator + ) +else: + from pydantic import ( + BaseModel, + Field, + validator + ) + +metamodel_version = "None" +version = "None" + + +class WeakRefShimBaseModel(BaseModel): + __slots__ = '__weakref__' + +class ConfiguredBaseModel(WeakRefShimBaseModel, + validate_assignment = True, + validate_all = True, + underscore_attrs_are_private = True, + extra = "forbid", + arbitrary_types_allowed = True, + use_enum_values = True): + pass + + +class RelativeTimeEnum(str, Enum): + BEFORE = "BEFORE" + AFTER = "AFTER" + AT_SAME_TIME_AS = "AT_SAME_TIME_AS" + + +class HumanLanguageCodeEnum(str): + """ + An enumeration of languages + """ + pass + + +class PersonStatus(str, Enum): + # the person is living + ALIVE = "ALIVE" + # the person is deceased + DEAD = "DEAD" + # the vital status is not known + UNKNOWN = "UNKNOWN" + + +class CaseOrControlEnum(str, Enum): + case_role_in_case_control_study = "CASE" + control_role_in_case_control_study = "CONTROL" + + +class StudyDesignEnum(str): + pass + + +class InvestigativeProtocolEnum(str): + pass + + +class SampleProcessingEnum(str): + pass + + +class Identified(ConfiguredBaseModel): + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + + +class Typed(ConfiguredBaseModel): + type: Literal["Typed"] = Field("Typed", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Entity(Typed): + """ + A physical, digital, conceptual, or other kind of thing with some common characteristics + """ + type: Literal["Entity"] = Field("Entity", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Intangible(Entity): + """ + An entity that is not a physical object, process, or information + """ + type: Literal["Intangible"] = Field("Intangible", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class NamedThing(Entity, Identified): + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["NamedThing"] = Field("NamedThing", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Concept(Intangible, Identified): + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Concept"] = Field("Concept", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class InformationEntity(Intangible, Identified): + """ + An entity that describes some information + """ + describes: Optional[Any] = Field(None, description="""The thing that is being described""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["InformationEntity"] = Field("InformationEntity", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class PhysicalDevice(NamedThing): + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["PhysicalDevice"] = Field("PhysicalDevice", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class StructuredValue(Intangible): + """ + A value that is a structured collection of other values + """ + type: Literal["StructuredValue"] = Field("StructuredValue", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Role(Intangible): + type: Literal["Role"] = Field("Role", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Relationship(Intangible): + type: Literal["Relationship"] = Field("Relationship", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Location(StructuredValue): + type: Literal["Location"] = Field("Location", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class PointLocation(Location): + type: Literal["PointLocation"] = Field("PointLocation", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Specification(InformationEntity): + """ + A specification of a thing + """ + describes: Optional[Any] = Field(None, description="""The thing that is being described""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Specification"] = Field("Specification", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Procedure(Specification): + """ + A canonical series of actions conducted in a certain order or manner + """ + describes: Optional[Any] = Field(None, description="""The thing that is being described""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Procedure"] = Field("Procedure", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class EntitySet(Intangible): + """ + A group of things. The collection may be heterogeneous or homogeneous. + """ + members: Optional[List[Union[Entity,Intangible,NamedThing,Event,Variable,LifeEvent,ExecutionOfProcedure,Observation,Investigation,Measurement,PlannedProcess,MathematicalOperationExecution,MaterialCollection,MaterialProcessing,InvestigativeProcess,SampleCollectionProcess,DataGenerationFromSample,SampleProcessing,PhysicalDevice,Agent,CreativeWork,SampleMaterial,Person,Organization,AutomatedAgent,Concept,InformationEntity,StructuredValue,Role,Relationship,EntitySet,TimePointOrTemporalInterval,Service,Quantity,QuantityRange,Duration,SimpleQuantity,Ratio,TemporalInterval,TimePoint,TemporalRelationship,Location,PointLocation,Specification,Publication,Dataset,Procedure,InvestigativeProtocol,StudyDesign,QuantityKind,UnitConcept]]] = Field(default_factory=list, description="""The members of the collection""") + type: Literal["EntitySet"] = Field("EntitySet", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Event(Entity, Identified): + """ + A thing that happens + """ + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + happens_at: Optional[TimePoint] = Field(None) + has_interval: Optional[TemporalInterval] = Field(None) + has_duration: Optional[Duration] = Field(None) + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Event"] = Field("Event", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class TimePointOrTemporalInterval(Intangible): + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + type: Literal["TimePointOrTemporalInterval"] = Field("TimePointOrTemporalInterval", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class TemporalInterval(TimePointOrTemporalInterval): + """ + A period of time + """ + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + type: Literal["TemporalInterval"] = Field("TemporalInterval", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class TimePoint(TimePointOrTemporalInterval): + """ + A point in time. Can be fully specified, or specified in relative terms. + """ + year_value: Optional[int] = Field(None) + date_value: Optional[date] = Field(None) + time_value: Optional[str] = Field(None) + datetime_value: Optional[datetime ] = Field(None) + marker_event: Optional[str] = Field(None) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + type: Literal["TimePoint"] = Field("TimePoint", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class TemporalRelationship(Relationship): + """ + A relationship to another time point + """ + predicate: Optional[RelativeTimeEnum] = Field(None, description="""The relationship between the two time points""") + relative_to: Optional[Union[TemporalInterval, TimePoint, str]] = Field(None) + type: Literal["TemporalRelationship"] = Field("TemporalRelationship", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Agent(NamedThing): + """ + Represents an Agent + """ + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Agent"] = Field("Agent", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Person(Agent): + """ + Represents a Person + """ + primary_email: Optional[str] = Field(None, description="""The main email address of a person""") + birth_date: Optional[date] = Field(None, description="""Date on which a person is born""") + age_in_years: Optional[int] = Field(None, description="""Number of years since birth""") + vital_status: Optional[PersonStatus] = Field(None, description="""living or dead status""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Person"] = Field("Person", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + @validator('primary_email', allow_reuse=True) + def pattern_primary_email(cls, v): + pattern=re.compile(r"^\S+@[\S+\.]+\S+") + if isinstance(v,list): + for element in v: + if not pattern.match(element): + raise ValueError(f"Invalid primary_email format: {element}") + elif isinstance(v,str): + if not pattern.match(v): + raise ValueError(f"Invalid primary_email format: {v}") + return v + + +class Organization(Agent): + """ + Represents an Organization + """ + provides_services: Optional[List[Service]] = Field(default_factory=list) + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Organization"] = Field("Organization", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class AutomatedAgent(Agent): + """ + Represents an Automated Agent + """ + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["AutomatedAgent"] = Field("AutomatedAgent", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class LifeEvent(Event): + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + happens_at: Optional[TimePoint] = Field(None) + has_interval: Optional[TemporalInterval] = Field(None) + has_duration: Optional[Duration] = Field(None) + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["LifeEvent"] = Field("LifeEvent", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class CreationMetadata(ConfiguredBaseModel): + title: Optional[str] = Field(None, description="""The title of the item""") + abstract: Optional[str] = Field(None, description="""A summary of the item""") + rights: Optional[str] = Field(None, description="""Information about rights held in and over the item""") + creators: Optional[List[str]] = Field(default_factory=list, description="""The person or organization who created the work""") + contributors: Optional[List[str]] = Field(default_factory=list, description="""A person or organization that contributed to the creation of the work""") + contacts: Optional[List[str]] = Field(default_factory=list, description="""A contact point for a person or organization""") + keywords: Optional[List[str]] = Field(default_factory=list, description="""Keywords or tags used to describe this item""") + + +class CreativeWork(CreationMetadata, NamedThing): + """ + The most generic kind of creative work, including books, movies, photographs, software programs, etc. + """ + title: Optional[str] = Field(None, description="""The title of the item""") + abstract: Optional[str] = Field(None, description="""A summary of the item""") + rights: Optional[str] = Field(None, description="""Information about rights held in and over the item""") + creators: Optional[List[str]] = Field(default_factory=list, description="""The person or organization who created the work""") + contributors: Optional[List[str]] = Field(default_factory=list, description="""A person or organization that contributed to the creation of the work""") + contacts: Optional[List[str]] = Field(default_factory=list, description="""A contact point for a person or organization""") + keywords: Optional[List[str]] = Field(default_factory=list, description="""Keywords or tags used to describe this item""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["CreativeWork"] = Field("CreativeWork", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Service(Intangible): + """ + A service provided by an organization + """ + type: Literal["Service"] = Field("Service", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Publication(InformationEntity): + describes: Optional[Any] = Field(None, description="""The thing that is being described""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Publication"] = Field("Publication", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Variable(Entity): + allowed_units: Optional[List[str]] = Field(default_factory=list, description="""The units that are allowed for this variable""") + type: Literal["Variable"] = Field("Variable", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class QuantityKind(Concept): + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["QuantityKind"] = Field("QuantityKind", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Quantity(Intangible): + has_quantity_kind: Optional[str] = Field(None, description="""The kind of quantity""") + type: Literal["Quantity"] = Field("Quantity", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Duration(Quantity): + """ + A length of time + """ + has_quantity_kind: Optional[str] = Field(None, description="""The kind of quantity""") + type: Literal["Duration"] = Field("Duration", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class SimpleQuantity(Quantity): + """ + A quantity is a property that can be measured or counted + """ + value: Optional[float] = Field(None, description="""The value of the quantity""") + unit: Optional[str] = Field(None) + has_quantity_kind: Optional[str] = Field(None, description="""The kind of quantity""") + type: Literal["SimpleQuantity"] = Field("SimpleQuantity", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Ratio(Quantity): + """ + A tuple of two quantities + """ + numerator: Optional[Union[Quantity,Duration,SimpleQuantity,Ratio]] = Field(None, description="""The numerator of the ratio""") + denominator: Optional[Union[Quantity,Duration,SimpleQuantity,Ratio]] = Field(None, description="""The denominator of the ratio""") + has_quantity_kind: Optional[str] = Field(None, description="""The kind of quantity""") + type: Literal["Ratio"] = Field("Ratio", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class QuantityRange(Intangible): + """ + A quantity range is a property that can be measured or counted + """ + lower_bound: Optional[Union[Quantity,Duration,SimpleQuantity,Ratio]] = Field(None, description="""The lower bound of the range""") + upper_bound: Optional[Union[Quantity,Duration,SimpleQuantity,Ratio]] = Field(None, description="""The upper bound of the range""") + type: Literal["QuantityRange"] = Field("QuantityRange", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class UnitConcept(Concept): + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["UnitConcept"] = Field("UnitConcept", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class ExecutionOfProcedure(Event): + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + happens_at: Optional[TimePoint] = Field(None) + has_interval: Optional[TemporalInterval] = Field(None) + has_duration: Optional[Duration] = Field(None) + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["ExecutionOfProcedure"] = Field("ExecutionOfProcedure", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class PlannedProcess(ExecutionOfProcedure): + """ + A process that follows a defined procedure or plan + """ + follows_procedure: Optional[str] = Field(None) + uses_physical_device: Optional[str] = Field(None) + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + happens_at: Optional[TimePoint] = Field(None) + has_interval: Optional[TemporalInterval] = Field(None) + has_duration: Optional[Duration] = Field(None) + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["PlannedProcess"] = Field("PlannedProcess", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class MathematicalOperationExecution(PlannedProcess): + """ + Application of a mathematical operation to one or more inputs to produce one or more outputs + """ + inputs: Optional[List[Any]] = Field(default_factory=list, description="""The inputs to the operation""") + outputs: Optional[List[Any]] = Field(default_factory=list, description="""The outputs of the operation""") + parts: Optional[List[str]] = Field(default_factory=list, description="""The parts of the process""") + immediate_preceding_steps: Optional[List[str]] = Field(default_factory=list, description="""The steps that immediately precede this step""") + follows_procedure: Optional[str] = Field(None) + uses_physical_device: Optional[str] = Field(None) + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + happens_at: Optional[TimePoint] = Field(None) + has_interval: Optional[TemporalInterval] = Field(None) + has_duration: Optional[Duration] = Field(None) + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["MathematicalOperationExecution"] = Field("MathematicalOperationExecution", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class MaterialCollection(PlannedProcess): + follows_procedure: Optional[str] = Field(None) + uses_physical_device: Optional[str] = Field(None) + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + happens_at: Optional[TimePoint] = Field(None) + has_interval: Optional[TemporalInterval] = Field(None) + has_duration: Optional[Duration] = Field(None) + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["MaterialCollection"] = Field("MaterialCollection", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class MaterialProcessing(PlannedProcess): + follows_procedure: Optional[str] = Field(None) + uses_physical_device: Optional[str] = Field(None) + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + happens_at: Optional[TimePoint] = Field(None) + has_interval: Optional[TemporalInterval] = Field(None) + has_duration: Optional[Duration] = Field(None) + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["MaterialProcessing"] = Field("MaterialProcessing", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Observation(Event): + """ + A statement about the state of something + """ + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + happens_at: Optional[TimePoint] = Field(None) + has_interval: Optional[TemporalInterval] = Field(None) + has_duration: Optional[Duration] = Field(None) + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Observation"] = Field("Observation", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Measurement(Observation): + quantity_measured: Optional[Union[Quantity,Duration,SimpleQuantity,Ratio]] = Field(None, description="""The quantity being measured""") + variable_measured: Optional[Variable] = Field(None, description="""The variable being measured""") + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + happens_at: Optional[TimePoint] = Field(None) + has_interval: Optional[TemporalInterval] = Field(None) + has_duration: Optional[Duration] = Field(None) + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Measurement"] = Field("Measurement", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Investigation(Event): + objectives: Optional[str] = Field(None) + variables: Optional[List[Variable]] = Field(default_factory=list) + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + happens_at: Optional[TimePoint] = Field(None) + has_interval: Optional[TemporalInterval] = Field(None) + has_duration: Optional[Duration] = Field(None) + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Investigation"] = Field("Investigation", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class InvestigativeProtocol(Procedure): + protocols_io_url: Optional[str] = Field(None) + describes: Optional[Any] = Field(None, description="""The thing that is being described""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["InvestigativeProtocol"] = Field("InvestigativeProtocol", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class StudyDesign(Procedure): + describes: Optional[Any] = Field(None, description="""The thing that is being described""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["StudyDesign"] = Field("StudyDesign", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class SampleMaterial(NamedThing): + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["SampleMaterial"] = Field("SampleMaterial", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class InvestigativeProcess(PlannedProcess): + follows_procedure: Optional[str] = Field(None) + part_of: Optional[str] = Field(None) + uses_physical_device: Optional[str] = Field(None) + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + happens_at: Optional[TimePoint] = Field(None) + has_interval: Optional[TemporalInterval] = Field(None) + has_duration: Optional[Duration] = Field(None) + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["InvestigativeProcess"] = Field("InvestigativeProcess", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class SampleCollectionProcess(InvestigativeProcess): + material_collected: Optional[str] = Field(None) + collected_from: Optional[str] = Field(None) + follows_procedure: Optional[str] = Field(None) + part_of: Optional[str] = Field(None) + uses_physical_device: Optional[str] = Field(None) + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + happens_at: Optional[TimePoint] = Field(None) + has_interval: Optional[TemporalInterval] = Field(None) + has_duration: Optional[Duration] = Field(None) + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["SampleCollectionProcess"] = Field("SampleCollectionProcess", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class SampleProcessing(MaterialProcessing): + follows_procedure: Optional[str] = Field(None) + uses_physical_device: Optional[str] = Field(None) + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + happens_at: Optional[TimePoint] = Field(None) + has_interval: Optional[TemporalInterval] = Field(None) + has_duration: Optional[Duration] = Field(None) + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["SampleProcessing"] = Field("SampleProcessing", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class DataGenerationFromSample(InvestigativeProcess): + follows_procedure: Optional[str] = Field(None) + part_of: Optional[str] = Field(None) + uses_physical_device: Optional[str] = Field(None) + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + happens_at: Optional[TimePoint] = Field(None) + has_interval: Optional[TemporalInterval] = Field(None) + has_duration: Optional[Duration] = Field(None) + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["DataGenerationFromSample"] = Field("DataGenerationFromSample", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Dataset(CreationMetadata, InformationEntity): + collected_as_part_of: Optional[List[str]] = Field(default_factory=list) + title: Optional[str] = Field(None, description="""The title of the item""") + abstract: Optional[str] = Field(None, description="""A summary of the item""") + rights: Optional[str] = Field(None, description="""Information about rights held in and over the item""") + creators: Optional[List[str]] = Field(default_factory=list, description="""The person or organization who created the work""") + contributors: Optional[List[str]] = Field(default_factory=list, description="""A person or organization that contributed to the creation of the work""") + contacts: Optional[List[str]] = Field(default_factory=list, description="""A contact point for a person or organization""") + keywords: Optional[List[str]] = Field(default_factory=list, description="""Keywords or tags used to describe this item""") + describes: Optional[Any] = Field(None, description="""The thing that is being described""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Dataset"] = Field("Dataset", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +# Update forward refs +# see https://pydantic-docs.helpmanual.io/usage/postponed_annotations/ +Identified.update_forward_refs() +Typed.update_forward_refs() +Entity.update_forward_refs() +Intangible.update_forward_refs() +NamedThing.update_forward_refs() +Concept.update_forward_refs() +InformationEntity.update_forward_refs() +PhysicalDevice.update_forward_refs() +StructuredValue.update_forward_refs() +Role.update_forward_refs() +Relationship.update_forward_refs() +Location.update_forward_refs() +PointLocation.update_forward_refs() +Specification.update_forward_refs() +Procedure.update_forward_refs() +EntitySet.update_forward_refs() +Event.update_forward_refs() +TimePointOrTemporalInterval.update_forward_refs() +TemporalInterval.update_forward_refs() +TimePoint.update_forward_refs() +TemporalRelationship.update_forward_refs() +Agent.update_forward_refs() +Person.update_forward_refs() +Organization.update_forward_refs() +AutomatedAgent.update_forward_refs() +LifeEvent.update_forward_refs() +CreationMetadata.update_forward_refs() +CreativeWork.update_forward_refs() +Service.update_forward_refs() +Publication.update_forward_refs() +Variable.update_forward_refs() +QuantityKind.update_forward_refs() +Quantity.update_forward_refs() +Duration.update_forward_refs() +SimpleQuantity.update_forward_refs() +Ratio.update_forward_refs() +QuantityRange.update_forward_refs() +UnitConcept.update_forward_refs() +ExecutionOfProcedure.update_forward_refs() +PlannedProcess.update_forward_refs() +MathematicalOperationExecution.update_forward_refs() +MaterialCollection.update_forward_refs() +MaterialProcessing.update_forward_refs() +Observation.update_forward_refs() +Measurement.update_forward_refs() +Investigation.update_forward_refs() +InvestigativeProtocol.update_forward_refs() +StudyDesign.update_forward_refs() +SampleMaterial.update_forward_refs() +InvestigativeProcess.update_forward_refs() +SampleCollectionProcess.update_forward_refs() +SampleProcessing.update_forward_refs() +DataGenerationFromSample.update_forward_refs() +Dataset.update_forward_refs() + diff --git a/src/linkml_common/datamodel/energytechnology.py b/src/linkml_common/datamodel/energytechnology.py new file mode 100644 index 0000000..2cf8872 --- /dev/null +++ b/src/linkml_common/datamodel/energytechnology.py @@ -0,0 +1,969 @@ +from __future__ import annotations +from datetime import ( + datetime, + date +) +from decimal import Decimal +from enum import Enum +import re +import sys +from typing import ( + Any, + List, + Literal, + Dict, + Optional, + Union +) +from pydantic.version import VERSION as PYDANTIC_VERSION +if int(PYDANTIC_VERSION[0])>=2: + from pydantic import ( + BaseModel, + ConfigDict, + Field, + field_validator + ) +else: + from pydantic import ( + BaseModel, + Field, + validator + ) + +metamodel_version = "None" +version = "None" + + +class WeakRefShimBaseModel(BaseModel): + __slots__ = '__weakref__' + +class ConfiguredBaseModel(WeakRefShimBaseModel, + validate_assignment = True, + validate_all = True, + underscore_attrs_are_private = True, + extra = "forbid", + arbitrary_types_allowed = True, + use_enum_values = True): + pass + + +class RelativeTimeEnum(str, Enum): + BEFORE = "BEFORE" + AFTER = "AFTER" + AT_SAME_TIME_AS = "AT_SAME_TIME_AS" + + +class HumanLanguageCodeEnum(str): + """ + An enumeration of languages + """ + pass + + +class PersonStatus(str, Enum): + # the person is living + ALIVE = "ALIVE" + # the person is deceased + DEAD = "DEAD" + # the vital status is not known + UNKNOWN = "UNKNOWN" + + +class FinanicialOrganizationEnum(str): + pass + + +class FossilFuelType(str, Enum): + # Coal + COAL = "COAL" + # Natural gas + NATURAL_GAS = "NATURAL_GAS" + # Petroleum + PETROLEUM = "PETROLEUM" + + +class Identified(ConfiguredBaseModel): + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + + +class Typed(ConfiguredBaseModel): + type: Literal["Typed"] = Field("Typed", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Entity(Typed): + """ + A physical, digital, conceptual, or other kind of thing with some common characteristics + """ + type: Literal["Entity"] = Field("Entity", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Intangible(Entity): + """ + An entity that is not a physical object, process, or information + """ + type: Literal["Intangible"] = Field("Intangible", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class NamedThing(Entity, Identified): + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["NamedThing"] = Field("NamedThing", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Concept(Intangible, Identified): + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Concept"] = Field("Concept", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class InformationEntity(Intangible, Identified): + """ + An entity that describes some information + """ + describes: Optional[Any] = Field(None, description="""The thing that is being described""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["InformationEntity"] = Field("InformationEntity", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class PhysicalDevice(NamedThing): + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["PhysicalDevice"] = Field("PhysicalDevice", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class StructuredValue(Intangible): + """ + A value that is a structured collection of other values + """ + type: Literal["StructuredValue"] = Field("StructuredValue", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Role(Intangible): + type: Literal["Role"] = Field("Role", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Relationship(Intangible): + type: Literal["Relationship"] = Field("Relationship", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Location(StructuredValue): + type: Literal["Location"] = Field("Location", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class PointLocation(Location): + type: Literal["PointLocation"] = Field("PointLocation", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Specification(InformationEntity): + """ + A specification of a thing + """ + describes: Optional[Any] = Field(None, description="""The thing that is being described""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Specification"] = Field("Specification", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Procedure(Specification): + """ + A canonical series of actions conducted in a certain order or manner + """ + describes: Optional[Any] = Field(None, description="""The thing that is being described""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Procedure"] = Field("Procedure", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class EntitySet(Intangible): + """ + A group of things. The collection may be heterogeneous or homogeneous. + """ + members: Optional[List[Union[Entity,Intangible,NamedThing,Event,Observation,EngineeringProcess,ExecutionOfProcedure,LifeEvent,PlannedProcess,MathematicalOperationExecution,MaterialCollection,MaterialProcessing,EngineeringMaterialProcessing,Measurement,PhysicalDevice,Place,RawMaterial,Equipment,BuiltEnvironmentFeature,Agent,CreativeWork,Person,Organization,AutomatedAgent,FinancialOrganization,Facility,BuiltSystem,ElectricalGrid,Building,PowerPlant,FossilFuelPlant,NuclearPlant,RenewablePlant,HydroelectricPlant,SolarPlant,WindFarm,Landform,Concept,InformationEntity,StructuredValue,Role,Relationship,EntitySet,Quantity,QuantityRange,Variable,TimePointOrTemporalInterval,Service,FinancialProduct,FinancialAccount,TemporalInterval,TimePoint,SimpleQuantity,Ratio,Duration,MoneyQuantity,TemporalRelationship,Location,PostalAddress,PointLocation,GeoBoxLocation,GeoPointLocation,Specification,Procedure,EngineeringSpecification,QuantityKind,UnitConcept,CurrencyConcept,PowerPlantType]]] = Field(default_factory=list, description="""The members of the collection""") + type: Literal["EntitySet"] = Field("EntitySet", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Place(NamedThing): + """ + Entities that have a somewhat fixed, physical extension. + """ + address: Optional[PostalAddress] = Field(None) + geolocation: Optional[GeoPointLocation] = Field(None, description="""The geolocation of the place""") + bounding_coordinates: Optional[GeoBoxLocation] = Field(None, description="""The bounding coordinates of the place""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Place"] = Field("Place", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Landform(Place): + """ + A natural feature of the solid surface of the Earth or other planetary body + """ + address: Optional[PostalAddress] = Field(None) + geolocation: Optional[GeoPointLocation] = Field(None, description="""The geolocation of the place""") + bounding_coordinates: Optional[GeoBoxLocation] = Field(None, description="""The bounding coordinates of the place""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Landform"] = Field("Landform", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class PostalAddress(StructuredValue): + """ + Represents an Address + """ + street_address: Optional[str] = Field(None, description="""The street address""") + street_address_additional: Optional[str] = Field(None) + city: Optional[str] = Field(None, description="""The city""") + state: Optional[str] = Field(None, description="""The state""") + postal_code: Optional[str] = Field(None, description="""The postal code or zip code""") + country: Optional[str] = Field(None, description="""The country""") + type: Literal["PostalAddress"] = Field("PostalAddress", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class GeoPointLocation(PointLocation): + latitude: Optional[Decimal] = Field(None, description="""The latitude of the location""") + longitude: Optional[Decimal] = Field(None, description="""The longitude of the location""") + altitude: Optional[Decimal] = Field(None, description="""The altitude of the location""") + type: Literal["GeoPointLocation"] = Field("GeoPointLocation", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class GeoBoxLocation(Location): + west_bounding_coordinate: Optional[Decimal] = Field(None, description="""The westernmost coordinate of the location""") + east_bounding_coordinate: Optional[Decimal] = Field(None, description="""The easternmost coordinate of the location""") + north_bounding_coordinate: Optional[Decimal] = Field(None, description="""The northernmost coordinate of the location""") + south_bounding_coordinate: Optional[Decimal] = Field(None, description="""The southernmost coordinate of the location""") + type: Literal["GeoBoxLocation"] = Field("GeoBoxLocation", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class QuantityKind(Concept): + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["QuantityKind"] = Field("QuantityKind", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Quantity(Intangible): + has_quantity_kind: Optional[str] = Field(None, description="""The kind of quantity""") + type: Literal["Quantity"] = Field("Quantity", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class SimpleQuantity(Quantity): + """ + A quantity is a property that can be measured or counted + """ + value: Optional[float] = Field(None, description="""The value of the quantity""") + unit: Optional[str] = Field(None) + has_quantity_kind: Optional[str] = Field(None, description="""The kind of quantity""") + type: Literal["SimpleQuantity"] = Field("SimpleQuantity", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Ratio(Quantity): + """ + A tuple of two quantities + """ + numerator: Optional[Union[Quantity,SimpleQuantity,Ratio,Duration,MoneyQuantity]] = Field(None, description="""The numerator of the ratio""") + denominator: Optional[Union[Quantity,SimpleQuantity,Ratio,Duration,MoneyQuantity]] = Field(None, description="""The denominator of the ratio""") + has_quantity_kind: Optional[str] = Field(None, description="""The kind of quantity""") + type: Literal["Ratio"] = Field("Ratio", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class QuantityRange(Intangible): + """ + A quantity range is a property that can be measured or counted + """ + lower_bound: Optional[Union[Quantity,SimpleQuantity,Ratio,Duration,MoneyQuantity]] = Field(None, description="""The lower bound of the range""") + upper_bound: Optional[Union[Quantity,SimpleQuantity,Ratio,Duration,MoneyQuantity]] = Field(None, description="""The upper bound of the range""") + type: Literal["QuantityRange"] = Field("QuantityRange", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class UnitConcept(Concept): + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["UnitConcept"] = Field("UnitConcept", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class EngineeringSpecification(Procedure): + describes: Optional[Any] = Field(None, description="""The thing that is being described""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["EngineeringSpecification"] = Field("EngineeringSpecification", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class RawMaterial(NamedThing): + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["RawMaterial"] = Field("RawMaterial", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Equipment(NamedThing): + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Equipment"] = Field("Equipment", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Variable(Intangible): + allowed_units: Optional[List[str]] = Field(default_factory=list, description="""The units that are allowed for this variable""") + type: Literal["Variable"] = Field("Variable", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Event(Entity, Identified): + """ + A thing that happens + """ + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + happens_at: Optional[TimePoint] = Field(None) + has_interval: Optional[TemporalInterval] = Field(None) + has_duration: Optional[Duration] = Field(None) + is_ongoing_as_of: Optional[TimePoint] = Field(None) + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Event"] = Field("Event", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Observation(Event): + """ + A statement about the state of something + """ + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + happens_at: Optional[TimePoint] = Field(None) + has_interval: Optional[TemporalInterval] = Field(None) + has_duration: Optional[Duration] = Field(None) + is_ongoing_as_of: Optional[TimePoint] = Field(None) + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Observation"] = Field("Observation", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class EngineeringProcess(Event): + follows_procedure: Optional[str] = Field(None) + part_of: Optional[str] = Field(None) + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + happens_at: Optional[TimePoint] = Field(None) + has_interval: Optional[TemporalInterval] = Field(None) + has_duration: Optional[Duration] = Field(None) + is_ongoing_as_of: Optional[TimePoint] = Field(None) + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["EngineeringProcess"] = Field("EngineeringProcess", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Measurement(Observation): + quantity_measured: Optional[Union[Quantity,SimpleQuantity,Ratio,Duration,MoneyQuantity]] = Field(None, description="""The quantity being measured""") + variable_measured: Optional[Variable] = Field(None, description="""The variable being measured""") + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + happens_at: Optional[TimePoint] = Field(None) + has_interval: Optional[TemporalInterval] = Field(None) + has_duration: Optional[Duration] = Field(None) + is_ongoing_as_of: Optional[TimePoint] = Field(None) + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Measurement"] = Field("Measurement", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class TimePointOrTemporalInterval(Intangible): + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + type: Literal["TimePointOrTemporalInterval"] = Field("TimePointOrTemporalInterval", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class TemporalInterval(TimePointOrTemporalInterval): + """ + A period of time + """ + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + type: Literal["TemporalInterval"] = Field("TemporalInterval", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class TimePoint(TimePointOrTemporalInterval): + """ + A point in time. Can be fully specified, or specified in relative terms. + """ + year_value: Optional[int] = Field(None) + date_value: Optional[date] = Field(None) + time_value: Optional[str] = Field(None) + datetime_value: Optional[datetime ] = Field(None) + marker_event: Optional[str] = Field(None) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + type: Literal["TimePoint"] = Field("TimePoint", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Duration(Quantity): + """ + A length of time + """ + has_quantity_kind: Optional[str] = Field(None, description="""The kind of quantity""") + type: Literal["Duration"] = Field("Duration", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class TemporalRelationship(Relationship): + """ + A relationship to another time point + """ + predicate: Optional[RelativeTimeEnum] = Field(None, description="""The relationship between the two time points""") + relative_to: Optional[Union[TemporalInterval, TimePoint, str]] = Field(None) + type: Literal["TemporalRelationship"] = Field("TemporalRelationship", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class ExecutionOfProcedure(Event): + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + happens_at: Optional[TimePoint] = Field(None) + has_interval: Optional[TemporalInterval] = Field(None) + has_duration: Optional[Duration] = Field(None) + is_ongoing_as_of: Optional[TimePoint] = Field(None) + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["ExecutionOfProcedure"] = Field("ExecutionOfProcedure", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class PlannedProcess(ExecutionOfProcedure): + """ + A process that follows a defined procedure or plan + """ + follows_procedure: Optional[str] = Field(None) + uses_physical_device: Optional[str] = Field(None) + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + happens_at: Optional[TimePoint] = Field(None) + has_interval: Optional[TemporalInterval] = Field(None) + has_duration: Optional[Duration] = Field(None) + is_ongoing_as_of: Optional[TimePoint] = Field(None) + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["PlannedProcess"] = Field("PlannedProcess", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class MathematicalOperationExecution(PlannedProcess): + """ + Application of a mathematical operation to one or more inputs to produce one or more outputs + """ + inputs: Optional[List[Any]] = Field(default_factory=list, description="""The inputs to the operation""") + outputs: Optional[List[Any]] = Field(default_factory=list, description="""The outputs of the operation""") + parts: Optional[List[str]] = Field(default_factory=list, description="""The parts of the process""") + immediate_preceding_steps: Optional[List[str]] = Field(default_factory=list, description="""The steps that immediately precede this step""") + follows_procedure: Optional[str] = Field(None) + uses_physical_device: Optional[str] = Field(None) + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + happens_at: Optional[TimePoint] = Field(None) + has_interval: Optional[TemporalInterval] = Field(None) + has_duration: Optional[Duration] = Field(None) + is_ongoing_as_of: Optional[TimePoint] = Field(None) + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["MathematicalOperationExecution"] = Field("MathematicalOperationExecution", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class MaterialCollection(PlannedProcess): + follows_procedure: Optional[str] = Field(None) + uses_physical_device: Optional[str] = Field(None) + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + happens_at: Optional[TimePoint] = Field(None) + has_interval: Optional[TemporalInterval] = Field(None) + has_duration: Optional[Duration] = Field(None) + is_ongoing_as_of: Optional[TimePoint] = Field(None) + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["MaterialCollection"] = Field("MaterialCollection", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class MaterialProcessing(PlannedProcess): + follows_procedure: Optional[str] = Field(None) + uses_physical_device: Optional[str] = Field(None) + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + happens_at: Optional[TimePoint] = Field(None) + has_interval: Optional[TemporalInterval] = Field(None) + has_duration: Optional[Duration] = Field(None) + is_ongoing_as_of: Optional[TimePoint] = Field(None) + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["MaterialProcessing"] = Field("MaterialProcessing", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class EngineeringMaterialProcessing(MaterialProcessing): + follows_procedure: Optional[str] = Field(None) + uses_physical_device: Optional[str] = Field(None) + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + happens_at: Optional[TimePoint] = Field(None) + has_interval: Optional[TemporalInterval] = Field(None) + has_duration: Optional[Duration] = Field(None) + is_ongoing_as_of: Optional[TimePoint] = Field(None) + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["EngineeringMaterialProcessing"] = Field("EngineeringMaterialProcessing", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class BuiltEnvironmentFeature(NamedThing): + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["BuiltEnvironmentFeature"] = Field("BuiltEnvironmentFeature", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Facility(BuiltEnvironmentFeature): + located_at_place: Optional[str] = Field(None, description="""The place where the entity is located""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Facility"] = Field("Facility", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Building(Facility): + located_at_place: Optional[str] = Field(None, description="""The place where the entity is located""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Building"] = Field("Building", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class BuiltSystem(BuiltEnvironmentFeature): + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["BuiltSystem"] = Field("BuiltSystem", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Agent(NamedThing): + """ + Represents an Agent + """ + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Agent"] = Field("Agent", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Person(Agent): + """ + Represents a Person + """ + primary_email: Optional[str] = Field(None, description="""The main email address of a person""") + birth_date: Optional[date] = Field(None, description="""Date on which a person is born""") + age_in_years: Optional[int] = Field(None, description="""Number of years since birth""") + vital_status: Optional[PersonStatus] = Field(None, description="""living or dead status""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Person"] = Field("Person", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + @validator('primary_email', allow_reuse=True) + def pattern_primary_email(cls, v): + pattern=re.compile(r"^\S+@[\S+\.]+\S+") + if isinstance(v,list): + for element in v: + if not pattern.match(element): + raise ValueError(f"Invalid primary_email format: {element}") + elif isinstance(v,str): + if not pattern.match(v): + raise ValueError(f"Invalid primary_email format: {v}") + return v + + +class Organization(Agent): + """ + Represents an Organization + """ + provides_services: Optional[List[Union[Service,FinancialProduct,FinancialAccount]]] = Field(default_factory=list) + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Organization"] = Field("Organization", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class AutomatedAgent(Agent): + """ + Represents an Automated Agent + """ + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["AutomatedAgent"] = Field("AutomatedAgent", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class LifeEvent(Event): + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + happens_at: Optional[TimePoint] = Field(None) + has_interval: Optional[TemporalInterval] = Field(None) + has_duration: Optional[Duration] = Field(None) + is_ongoing_as_of: Optional[TimePoint] = Field(None) + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["LifeEvent"] = Field("LifeEvent", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class CreationMetadata(ConfiguredBaseModel): + title: Optional[str] = Field(None, description="""The title of the item""") + abstract: Optional[str] = Field(None, description="""A summary of the item""") + rights: Optional[str] = Field(None, description="""Information about rights held in and over the item""") + creators: Optional[List[str]] = Field(default_factory=list, description="""The person or organization who created the work""") + contributors: Optional[List[str]] = Field(default_factory=list, description="""A person or organization that contributed to the creation of the work""") + contacts: Optional[List[str]] = Field(default_factory=list, description="""A contact point for a person or organization""") + keywords: Optional[List[str]] = Field(default_factory=list, description="""Keywords or tags used to describe this item""") + + +class CreativeWork(CreationMetadata, NamedThing): + """ + The most generic kind of creative work, including books, movies, photographs, software programs, etc. + """ + title: Optional[str] = Field(None, description="""The title of the item""") + abstract: Optional[str] = Field(None, description="""A summary of the item""") + rights: Optional[str] = Field(None, description="""Information about rights held in and over the item""") + creators: Optional[List[str]] = Field(default_factory=list, description="""The person or organization who created the work""") + contributors: Optional[List[str]] = Field(default_factory=list, description="""A person or organization that contributed to the creation of the work""") + contacts: Optional[List[str]] = Field(default_factory=list, description="""A contact point for a person or organization""") + keywords: Optional[List[str]] = Field(default_factory=list, description="""Keywords or tags used to describe this item""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["CreativeWork"] = Field("CreativeWork", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Service(Intangible): + """ + A service provided by an organization + """ + type: Literal["Service"] = Field("Service", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class MoneyQuantity(SimpleQuantity): + """ + A quantity of money + """ + value: Optional[float] = Field(None, description="""The value of the quantity""") + unit: Optional[str] = Field(None, description="""The currency of the quantity""") + has_quantity_kind: Optional[str] = Field(None, description="""The kind of quantity""") + type: Literal["MoneyQuantity"] = Field("MoneyQuantity", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class CurrencyConcept(Concept): + """ + A currency + """ + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["CurrencyConcept"] = Field("CurrencyConcept", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class FinancialProduct(Service): + """ + A product or service offered by a bank whereby one may deposit, withdraw or transfer money and in some cases be paid interest. + """ + type: Literal["FinancialProduct"] = Field("FinancialProduct", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class FinancialAccount(FinancialProduct): + """ + A bank account + """ + account_number: Optional[str] = Field(None, description="""The account number""") + bank: Optional[str] = Field(None, description="""The bank that holds the account""") + account_holder: Optional[str] = Field(None, description="""The person or organization that holds the account""") + type: Literal["FinancialAccount"] = Field("FinancialAccount", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class FinancialOrganization(Organization): + """ + An organization that provides financial services + """ + provides_services: Optional[List[Union[Service,FinancialProduct,FinancialAccount]]] = Field(default_factory=list) + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["FinancialOrganization"] = Field("FinancialOrganization", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class PowerPlant(Building): + """ + A facility for generating electrical power + """ + plant_type: Optional[str] = Field(None) + location: Optional[str] = Field(None) + operator: Optional[str] = Field(None) + capacity: Optional[Union[SimpleQuantity,MoneyQuantity]] = Field(None) + commissioning_date: Optional[date] = Field(None) + decommissioning_date: Optional[date] = Field(None) + capex: Optional[MoneyQuantity] = Field(None, description="""Capital expenditure for the plant""") + opex: Optional[MoneyQuantity] = Field(None, description="""Operating expense for the plant""") + located_at_place: Optional[str] = Field(None, description="""The place where the entity is located""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["PowerPlant"] = Field("PowerPlant", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class PowerPlantType(Concept): + """ + The type of power plant + """ + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["PowerPlantType"] = Field("PowerPlantType", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class FossilFuelPlant(PowerPlant): + """ + A power plant that uses fossil fuels + """ + fuel: Optional[FossilFuelType] = Field(None) + plant_type: Optional[str] = Field(None) + location: Optional[str] = Field(None) + operator: Optional[str] = Field(None) + capacity: Optional[Union[SimpleQuantity,MoneyQuantity]] = Field(None) + commissioning_date: Optional[date] = Field(None) + decommissioning_date: Optional[date] = Field(None) + capex: Optional[MoneyQuantity] = Field(None, description="""Capital expenditure for the plant""") + opex: Optional[MoneyQuantity] = Field(None, description="""Operating expense for the plant""") + located_at_place: Optional[str] = Field(None, description="""The place where the entity is located""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["FossilFuelPlant"] = Field("FossilFuelPlant", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class NuclearPlant(PowerPlant): + """ + A nuclear power plant + """ + plant_type: Optional[str] = Field(None) + location: Optional[str] = Field(None) + operator: Optional[str] = Field(None) + capacity: Optional[Union[SimpleQuantity,MoneyQuantity]] = Field(None) + commissioning_date: Optional[date] = Field(None) + decommissioning_date: Optional[date] = Field(None) + capex: Optional[MoneyQuantity] = Field(None, description="""Capital expenditure for the plant""") + opex: Optional[MoneyQuantity] = Field(None, description="""Operating expense for the plant""") + located_at_place: Optional[str] = Field(None, description="""The place where the entity is located""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["NuclearPlant"] = Field("NuclearPlant", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class RenewablePlant(PowerPlant): + """ + A power plant that uses renewable energy sources + """ + plant_type: Optional[str] = Field(None) + location: Optional[str] = Field(None) + operator: Optional[str] = Field(None) + capacity: Optional[Union[SimpleQuantity,MoneyQuantity]] = Field(None) + commissioning_date: Optional[date] = Field(None) + decommissioning_date: Optional[date] = Field(None) + capex: Optional[MoneyQuantity] = Field(None, description="""Capital expenditure for the plant""") + opex: Optional[MoneyQuantity] = Field(None, description="""Operating expense for the plant""") + located_at_place: Optional[str] = Field(None, description="""The place where the entity is located""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["RenewablePlant"] = Field("RenewablePlant", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class HydroelectricPlant(RenewablePlant): + """ + A hydroelectric power plant + """ + dam: Optional[str] = Field(None, description="""The dam used by the hydroelectric plant""") + plant_type: Optional[str] = Field(None) + location: Optional[str] = Field(None) + operator: Optional[str] = Field(None) + capacity: Optional[Union[SimpleQuantity,MoneyQuantity]] = Field(None) + commissioning_date: Optional[date] = Field(None) + decommissioning_date: Optional[date] = Field(None) + capex: Optional[MoneyQuantity] = Field(None, description="""Capital expenditure for the plant""") + opex: Optional[MoneyQuantity] = Field(None, description="""Operating expense for the plant""") + located_at_place: Optional[str] = Field(None, description="""The place where the entity is located""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["HydroelectricPlant"] = Field("HydroelectricPlant", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class SolarPlant(RenewablePlant): + """ + A solar power plant + """ + plant_type: Optional[str] = Field(None) + location: Optional[str] = Field(None) + operator: Optional[str] = Field(None) + capacity: Optional[Union[SimpleQuantity,MoneyQuantity]] = Field(None) + commissioning_date: Optional[date] = Field(None) + decommissioning_date: Optional[date] = Field(None) + capex: Optional[MoneyQuantity] = Field(None, description="""Capital expenditure for the plant""") + opex: Optional[MoneyQuantity] = Field(None, description="""Operating expense for the plant""") + located_at_place: Optional[str] = Field(None, description="""The place where the entity is located""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["SolarPlant"] = Field("SolarPlant", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class WindFarm(RenewablePlant): + """ + A wind farm + """ + plant_type: Optional[str] = Field(None) + location: Optional[str] = Field(None) + operator: Optional[str] = Field(None) + capacity: Optional[Union[SimpleQuantity,MoneyQuantity]] = Field(None) + commissioning_date: Optional[date] = Field(None) + decommissioning_date: Optional[date] = Field(None) + capex: Optional[MoneyQuantity] = Field(None, description="""Capital expenditure for the plant""") + opex: Optional[MoneyQuantity] = Field(None, description="""Operating expense for the plant""") + located_at_place: Optional[str] = Field(None, description="""The place where the entity is located""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["WindFarm"] = Field("WindFarm", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class ElectricalGrid(BuiltSystem): + """ + A network of electrical transmission lines + """ + plants: Optional[List[str]] = Field(default_factory=list) + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["ElectricalGrid"] = Field("ElectricalGrid", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +# Update forward refs +# see https://pydantic-docs.helpmanual.io/usage/postponed_annotations/ +Identified.update_forward_refs() +Typed.update_forward_refs() +Entity.update_forward_refs() +Intangible.update_forward_refs() +NamedThing.update_forward_refs() +Concept.update_forward_refs() +InformationEntity.update_forward_refs() +PhysicalDevice.update_forward_refs() +StructuredValue.update_forward_refs() +Role.update_forward_refs() +Relationship.update_forward_refs() +Location.update_forward_refs() +PointLocation.update_forward_refs() +Specification.update_forward_refs() +Procedure.update_forward_refs() +EntitySet.update_forward_refs() +Place.update_forward_refs() +Landform.update_forward_refs() +PostalAddress.update_forward_refs() +GeoPointLocation.update_forward_refs() +GeoBoxLocation.update_forward_refs() +QuantityKind.update_forward_refs() +Quantity.update_forward_refs() +SimpleQuantity.update_forward_refs() +Ratio.update_forward_refs() +QuantityRange.update_forward_refs() +UnitConcept.update_forward_refs() +EngineeringSpecification.update_forward_refs() +RawMaterial.update_forward_refs() +Equipment.update_forward_refs() +Variable.update_forward_refs() +Event.update_forward_refs() +Observation.update_forward_refs() +EngineeringProcess.update_forward_refs() +Measurement.update_forward_refs() +TimePointOrTemporalInterval.update_forward_refs() +TemporalInterval.update_forward_refs() +TimePoint.update_forward_refs() +Duration.update_forward_refs() +TemporalRelationship.update_forward_refs() +ExecutionOfProcedure.update_forward_refs() +PlannedProcess.update_forward_refs() +MathematicalOperationExecution.update_forward_refs() +MaterialCollection.update_forward_refs() +MaterialProcessing.update_forward_refs() +EngineeringMaterialProcessing.update_forward_refs() +BuiltEnvironmentFeature.update_forward_refs() +Facility.update_forward_refs() +Building.update_forward_refs() +BuiltSystem.update_forward_refs() +Agent.update_forward_refs() +Person.update_forward_refs() +Organization.update_forward_refs() +AutomatedAgent.update_forward_refs() +LifeEvent.update_forward_refs() +CreationMetadata.update_forward_refs() +CreativeWork.update_forward_refs() +Service.update_forward_refs() +MoneyQuantity.update_forward_refs() +CurrencyConcept.update_forward_refs() +FinancialProduct.update_forward_refs() +FinancialAccount.update_forward_refs() +FinancialOrganization.update_forward_refs() +PowerPlant.update_forward_refs() +PowerPlantType.update_forward_refs() +FossilFuelPlant.update_forward_refs() +NuclearPlant.update_forward_refs() +RenewablePlant.update_forward_refs() +HydroelectricPlant.update_forward_refs() +SolarPlant.update_forward_refs() +WindFarm.update_forward_refs() +ElectricalGrid.update_forward_refs() + diff --git a/src/linkml_common/datamodel/engineering.py b/src/linkml_common/datamodel/engineering.py new file mode 100644 index 0000000..43dff23 --- /dev/null +++ b/src/linkml_common/datamodel/engineering.py @@ -0,0 +1,462 @@ +from __future__ import annotations +from datetime import ( + datetime, + date +) +from decimal import Decimal +from enum import Enum +import re +import sys +from typing import ( + Any, + List, + Literal, + Dict, + Optional, + Union +) +from pydantic.version import VERSION as PYDANTIC_VERSION +if int(PYDANTIC_VERSION[0])>=2: + from pydantic import ( + BaseModel, + ConfigDict, + Field, + field_validator + ) +else: + from pydantic import ( + BaseModel, + Field, + validator + ) + +metamodel_version = "None" +version = "None" + + +class WeakRefShimBaseModel(BaseModel): + __slots__ = '__weakref__' + +class ConfiguredBaseModel(WeakRefShimBaseModel, + validate_assignment = True, + validate_all = True, + underscore_attrs_are_private = True, + extra = "forbid", + arbitrary_types_allowed = True, + use_enum_values = True): + pass + + +class RelativeTimeEnum(str, Enum): + BEFORE = "BEFORE" + AFTER = "AFTER" + AT_SAME_TIME_AS = "AT_SAME_TIME_AS" + + +class Entity(ConfiguredBaseModel): + """ + A physical, digital, conceptual, or other kind of thing with some common characteristics + """ + type: Literal["Entity"] = Field("Entity", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Variable(Entity): + allowed_units: Optional[List[str]] = Field(default_factory=list, description="""The units that are allowed for this variable""") + type: Literal["Variable"] = Field("Variable", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class NamedThing(Entity): + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["NamedThing"] = Field("NamedThing", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + +class Event(NamedThing): + """ + A thing that happens + """ + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + happens_at: Optional[TimePoint] = Field(None) + has_interval: Optional[TemporalInterval] = Field(None) + has_duration: Optional[Duration] = Field(None) + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Event"] = Field("Event", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + +class Concept(NamedThing): + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Concept"] = Field("Concept", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + +class QuantityKind(Concept): + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["QuantityKind"] = Field("QuantityKind", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + +class UnitConcept(Concept): + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["UnitConcept"] = Field("UnitConcept", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + +class InformationEntity(NamedThing): + """ + An entity that describes some information + """ + describes: Optional[Any] = Field(None, description="""The thing that is being described""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["InformationEntity"] = Field("InformationEntity", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + +class PhysicalDevice(NamedThing): + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["PhysicalDevice"] = Field("PhysicalDevice", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + +class Intangible(Entity): + """ + An entity that is not a physical object, process, or information + """ + type: Literal["Intangible"] = Field("Intangible", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class TimePointOrTemporalInterval(Intangible): + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + type: Literal["TimePointOrTemporalInterval"] = Field("TimePointOrTemporalInterval", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class TemporalInterval(TimePointOrTemporalInterval): + """ + A period of time + """ + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + type: Literal["TemporalInterval"] = Field("TemporalInterval", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class TimePoint(TimePointOrTemporalInterval): + """ + A point in time. Can be fully specified, or specified in relative terms. + """ + year_value: Optional[int] = Field(None) + date_value: Optional[date] = Field(None) + time_value: Optional[str] = Field(None) + datetime_value: Optional[datetime ] = Field(None) + marker_event: Optional[str] = Field(None) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + type: Literal["TimePoint"] = Field("TimePoint", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Quantity(Intangible): + has_quantity_kind: Optional[str] = Field(None, description="""The kind of quantity""") + type: Literal["Quantity"] = Field("Quantity", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Duration(Quantity): + """ + A length of time + """ + has_quantity_kind: Optional[str] = Field(None, description="""The kind of quantity""") + type: Literal["Duration"] = Field("Duration", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class SimpleQuantity(Quantity): + """ + A quantity is a property that can be measured or counted + """ + value: Optional[float] = Field(None, description="""The value of the quantity""") + unit: Optional[str] = Field(None) + has_quantity_kind: Optional[str] = Field(None, description="""The kind of quantity""") + type: Literal["SimpleQuantity"] = Field("SimpleQuantity", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Ratio(Quantity): + """ + A tuple of two quantities + """ + numerator: Optional[Union[Quantity,Duration,SimpleQuantity,Ratio]] = Field(None, description="""The numerator of the ratio""") + denominator: Optional[Union[Quantity,Duration,SimpleQuantity,Ratio]] = Field(None, description="""The denominator of the ratio""") + has_quantity_kind: Optional[str] = Field(None, description="""The kind of quantity""") + type: Literal["Ratio"] = Field("Ratio", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class QuantityRange(Intangible): + """ + A quantity range is a property that can be measured or counted + """ + lower_bound: Optional[Union[Quantity,Duration,SimpleQuantity,Ratio]] = Field(None, description="""The lower bound of the range""") + upper_bound: Optional[Union[Quantity,Duration,SimpleQuantity,Ratio]] = Field(None, description="""The upper bound of the range""") + type: Literal["QuantityRange"] = Field("QuantityRange", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Role(Intangible): + type: Literal["Role"] = Field("Role", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Relationship(Intangible): + type: Literal["Relationship"] = Field("Relationship", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class TemporalRelationship(Relationship): + """ + A relationship to another time point + """ + predicate: Optional[RelativeTimeEnum] = Field(None, description="""The relationship between the two time points""") + relative_to: Optional[Union[TemporalInterval, TimePoint, str]] = Field(None) + type: Literal["TemporalRelationship"] = Field("TemporalRelationship", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Location(ConfiguredBaseModel): + pass + + +class PointLocation(Location): + pass + + +class Observation(Entity): + """ + A statement about the state of something + """ + type: Literal["Observation"] = Field("Observation", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Measurement(Observation): + quantity_measured: Optional[Union[Quantity,Duration,SimpleQuantity,Ratio]] = Field(None, description="""The quantity being measured""") + variable_measured: Optional[Variable] = Field(None, description="""The variable being measured""") + type: Literal["Measurement"] = Field("Measurement", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Specification(NamedThing): + """ + A specification of a thing + """ + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Specification"] = Field("Specification", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + +class Procedure(Specification): + """ + A canonical series of actions conducted in a certain order or manner + """ + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Procedure"] = Field("Procedure", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + +class MathematicalOperation(ConfiguredBaseModel): + """ + Application of a mathematical operation to one or more inputs to produce one or more outputs + """ + inputs: Optional[List[Any]] = Field(default_factory=list, description="""The inputs to the operation""") + outputs: Optional[List[Any]] = Field(default_factory=list, description="""The outputs of the operation""") + parts: Optional[List[MathematicalOperation]] = Field(default_factory=list, description="""The parts of the process""") + immediate_preceding_steps: Optional[List[MathematicalOperation]] = Field(default_factory=list, description="""The steps that immediately precede this step""") + + +class UnitConversionOperation(MathematicalOperation): + """ + A unit conversion operation + """ + inputs: Optional[List[Union[Quantity,Duration,SimpleQuantity,Ratio]]] = Field(default_factory=list, description="""The input unit""") + outputs: Optional[List[Union[Quantity,Duration,SimpleQuantity,Ratio]]] = Field(default_factory=list, description="""The output unit""") + parts: Optional[List[MathematicalOperation]] = Field(default_factory=list, description="""The parts of the process""") + immediate_preceding_steps: Optional[List[MathematicalOperation]] = Field(default_factory=list, description="""The steps that immediately precede this step""") + + +class Collection(Intangible): + """ + A group of things. The collection may be heterogeneous or homogeneous. + """ + members: Optional[List[Union[Entity,Variable,NamedThing,Intangible,Observation,Measurement,TimePointOrTemporalInterval,Quantity,QuantityRange,Role,Relationship,Collection,TemporalRelationship,Duration,SimpleQuantity,Ratio,TemporalInterval,TimePoint,Event,Concept,InformationEntity,PhysicalDevice,Specification,RawMaterial,Equipment,Procedure,EngineeringSpecification,QuantityKind,UnitConcept,PlannedProcess,EngineeringProcess,MaterialCollection,MaterialProcessing,EngineeringMaterialProcessing]]] = Field(default_factory=list, description="""The members of the collection""") + type: Literal["Collection"] = Field("Collection", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class PlannedProcess(Event): + """ + A process that follows a defined procedure or plan + """ + follows_procedure: Optional[str] = Field(None) + uses_physical_device: Optional[str] = Field(None) + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + happens_at: Optional[TimePoint] = Field(None) + has_interval: Optional[TemporalInterval] = Field(None) + has_duration: Optional[Duration] = Field(None) + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["PlannedProcess"] = Field("PlannedProcess", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + +class MaterialCollection(PlannedProcess): + follows_procedure: Optional[str] = Field(None) + uses_physical_device: Optional[str] = Field(None) + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + happens_at: Optional[TimePoint] = Field(None) + has_interval: Optional[TemporalInterval] = Field(None) + has_duration: Optional[Duration] = Field(None) + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["MaterialCollection"] = Field("MaterialCollection", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + +class MaterialProcessing(PlannedProcess): + follows_procedure: Optional[str] = Field(None) + uses_physical_device: Optional[str] = Field(None) + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + happens_at: Optional[TimePoint] = Field(None) + has_interval: Optional[TemporalInterval] = Field(None) + has_duration: Optional[Duration] = Field(None) + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["MaterialProcessing"] = Field("MaterialProcessing", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + +class EngineeringSpecification(Procedure): + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["EngineeringSpecification"] = Field("EngineeringSpecification", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + +class RawMaterial(NamedThing): + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["RawMaterial"] = Field("RawMaterial", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + +class EngineeringProcess(Event): + follows_procedure: Optional[str] = Field(None) + part_of: Optional[str] = Field(None) + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + happens_at: Optional[TimePoint] = Field(None) + has_interval: Optional[TemporalInterval] = Field(None) + has_duration: Optional[Duration] = Field(None) + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["EngineeringProcess"] = Field("EngineeringProcess", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + +class EngineeringMaterialProcessing(MaterialProcessing): + follows_procedure: Optional[str] = Field(None) + uses_physical_device: Optional[str] = Field(None) + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + happens_at: Optional[TimePoint] = Field(None) + has_interval: Optional[TemporalInterval] = Field(None) + has_duration: Optional[Duration] = Field(None) + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["EngineeringMaterialProcessing"] = Field("EngineeringMaterialProcessing", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + +class Equipment(NamedThing): + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Equipment"] = Field("Equipment", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + +# Update forward refs +# see https://pydantic-docs.helpmanual.io/usage/postponed_annotations/ +Entity.update_forward_refs() +Variable.update_forward_refs() +NamedThing.update_forward_refs() +Event.update_forward_refs() +Concept.update_forward_refs() +QuantityKind.update_forward_refs() +UnitConcept.update_forward_refs() +InformationEntity.update_forward_refs() +PhysicalDevice.update_forward_refs() +Intangible.update_forward_refs() +TimePointOrTemporalInterval.update_forward_refs() +TemporalInterval.update_forward_refs() +TimePoint.update_forward_refs() +Quantity.update_forward_refs() +Duration.update_forward_refs() +SimpleQuantity.update_forward_refs() +Ratio.update_forward_refs() +QuantityRange.update_forward_refs() +Role.update_forward_refs() +Relationship.update_forward_refs() +TemporalRelationship.update_forward_refs() +Location.update_forward_refs() +PointLocation.update_forward_refs() +Observation.update_forward_refs() +Measurement.update_forward_refs() +Specification.update_forward_refs() +Procedure.update_forward_refs() +MathematicalOperation.update_forward_refs() +UnitConversionOperation.update_forward_refs() +Collection.update_forward_refs() +PlannedProcess.update_forward_refs() +MaterialCollection.update_forward_refs() +MaterialProcessing.update_forward_refs() +EngineeringSpecification.update_forward_refs() +RawMaterial.update_forward_refs() +EngineeringProcess.update_forward_refs() +EngineeringMaterialProcessing.update_forward_refs() +Equipment.update_forward_refs() + diff --git a/src/linkml_common/datamodel/environmental.py b/src/linkml_common/datamodel/environmental.py new file mode 100644 index 0000000..901f7d8 --- /dev/null +++ b/src/linkml_common/datamodel/environmental.py @@ -0,0 +1,331 @@ +from __future__ import annotations +from datetime import ( + datetime, + date +) +from decimal import Decimal +from enum import Enum +import re +import sys +from typing import ( + Any, + List, + Literal, + Dict, + Optional, + Union +) +from pydantic.version import VERSION as PYDANTIC_VERSION +if int(PYDANTIC_VERSION[0])>=2: + from pydantic import ( + BaseModel, + ConfigDict, + Field, + field_validator + ) +else: + from pydantic import ( + BaseModel, + Field, + validator + ) + +metamodel_version = "None" +version = "None" + + +class WeakRefShimBaseModel(BaseModel): + __slots__ = '__weakref__' + +class ConfiguredBaseModel(WeakRefShimBaseModel, + validate_assignment = True, + validate_all = True, + underscore_attrs_are_private = True, + extra = "forbid", + arbitrary_types_allowed = True, + use_enum_values = True): + pass + + +class Identified(ConfiguredBaseModel): + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + + +class Typed(ConfiguredBaseModel): + type: Literal["Typed"] = Field("Typed", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Entity(Typed): + """ + A physical, digital, conceptual, or other kind of thing with some common characteristics + """ + type: Literal["Entity"] = Field("Entity", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class NamedThing(Entity, Identified): + type: Literal["NamedThing"] = Field("NamedThing", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + + +class Concept(NamedThing): + type: Literal["Concept"] = Field("Concept", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + + +class InformationEntity(NamedThing): + """ + An entity that describes some information + """ + describes: Optional[Any] = Field(None, description="""The thing that is being described""") + type: Literal["InformationEntity"] = Field("InformationEntity", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + + +class PhysicalDevice(NamedThing): + type: Literal["PhysicalDevice"] = Field("PhysicalDevice", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + + +class Intangible(Entity): + """ + An entity that is not a physical object, process, or information + """ + type: Literal["Intangible"] = Field("Intangible", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class StructuredValue(Intangible): + """ + A value that is a structured collection of other values + """ + type: Literal["StructuredValue"] = Field("StructuredValue", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Role(Intangible): + type: Literal["Role"] = Field("Role", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Relationship(Intangible): + type: Literal["Relationship"] = Field("Relationship", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Location(StructuredValue): + type: Literal["Location"] = Field("Location", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class PointLocation(Location): + type: Literal["PointLocation"] = Field("PointLocation", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Observation(Entity): + """ + A statement about the state of something + """ + type: Literal["Observation"] = Field("Observation", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Specification(NamedThing): + """ + A specification of a thing + """ + type: Literal["Specification"] = Field("Specification", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + + +class Procedure(Specification): + """ + A canonical series of actions conducted in a certain order or manner + """ + type: Literal["Procedure"] = Field("Procedure", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + + +class Collection(Intangible): + """ + A group of things. The collection may be heterogeneous or homogeneous. + """ + members: Optional[List[Union[Entity,NamedThing,Intangible,Observation,StructuredValue,Role,Relationship,Collection,Quantity,QuantityRange,SimpleQuantity,Ratio,Location,PostalAddress,PointLocation,GeoBoxLocation,GeoPointLocation,Concept,InformationEntity,PhysicalDevice,Specification,Place,Landform,EnvironmentalSite,Procedure,QuantityKind,UnitConcept]]] = Field(default_factory=list, description="""The members of the collection""") + type: Literal["Collection"] = Field("Collection", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class QuantityKind(Concept): + type: Literal["QuantityKind"] = Field("QuantityKind", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + + +class Quantity(Intangible): + has_quantity_kind: Optional[str] = Field(None, description="""The kind of quantity""") + type: Literal["Quantity"] = Field("Quantity", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class SimpleQuantity(Quantity): + """ + A quantity is a property that can be measured or counted + """ + value: Optional[float] = Field(None, description="""The value of the quantity""") + unit: Optional[str] = Field(None) + has_quantity_kind: Optional[str] = Field(None, description="""The kind of quantity""") + type: Literal["SimpleQuantity"] = Field("SimpleQuantity", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Ratio(Quantity): + """ + A tuple of two quantities + """ + numerator: Optional[Union[Quantity,SimpleQuantity,Ratio]] = Field(None, description="""The numerator of the ratio""") + denominator: Optional[Union[Quantity,SimpleQuantity,Ratio]] = Field(None, description="""The denominator of the ratio""") + has_quantity_kind: Optional[str] = Field(None, description="""The kind of quantity""") + type: Literal["Ratio"] = Field("Ratio", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class QuantityRange(Intangible): + """ + A quantity range is a property that can be measured or counted + """ + lower_bound: Optional[Union[Quantity,SimpleQuantity,Ratio]] = Field(None, description="""The lower bound of the range""") + upper_bound: Optional[Union[Quantity,SimpleQuantity,Ratio]] = Field(None, description="""The upper bound of the range""") + type: Literal["QuantityRange"] = Field("QuantityRange", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class UnitConcept(Concept): + type: Literal["UnitConcept"] = Field("UnitConcept", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + + +class Place(NamedThing): + """ + Entities that have a somewhat fixed, physical extension. + """ + address: Optional[PostalAddress] = Field(None) + geolocation: Optional[GeoPointLocation] = Field(None, description="""The geolocation of the place""") + bounding_coordinates: Optional[GeoBoxLocation] = Field(None, description="""The bounding coordinates of the place""") + type: Literal["Place"] = Field("Place", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + + +class Landform(Place): + """ + A natural feature of the solid surface of the Earth or other planetary body + """ + address: Optional[PostalAddress] = Field(None) + geolocation: Optional[GeoPointLocation] = Field(None, description="""The geolocation of the place""") + bounding_coordinates: Optional[GeoBoxLocation] = Field(None, description="""The bounding coordinates of the place""") + type: Literal["Landform"] = Field("Landform", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + + +class PostalAddress(StructuredValue): + """ + Represents an Address + """ + street_address: Optional[str] = Field(None, description="""The street address""") + street_address_additional: Optional[str] = Field(None) + city: Optional[str] = Field(None, description="""The city""") + state: Optional[str] = Field(None, description="""The state""") + postal_code: Optional[str] = Field(None, description="""The postal code or zip code""") + country: Optional[str] = Field(None, description="""The country""") + type: Literal["PostalAddress"] = Field("PostalAddress", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class GeoPointLocation(PointLocation): + latitude: Optional[Decimal] = Field(None, description="""The latitude of the location""") + longitude: Optional[Decimal] = Field(None, description="""The longitude of the location""") + altitude: Optional[Decimal] = Field(None, description="""The altitude of the location""") + type: Literal["GeoPointLocation"] = Field("GeoPointLocation", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class GeoBoxLocation(Location): + west_bounding_coordinate: Optional[Decimal] = Field(None, description="""The westernmost coordinate of the location""") + east_bounding_coordinate: Optional[Decimal] = Field(None, description="""The easternmost coordinate of the location""") + north_bounding_coordinate: Optional[Decimal] = Field(None, description="""The northernmost coordinate of the location""") + south_bounding_coordinate: Optional[Decimal] = Field(None, description="""The southernmost coordinate of the location""") + type: Literal["GeoBoxLocation"] = Field("GeoBoxLocation", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class EnvironmentalSite(Place): + """ + A location or site that is the subject of environmental monitoring + """ + address: Optional[PostalAddress] = Field(None) + geolocation: Optional[GeoPointLocation] = Field(None, description="""The geolocation of the place""") + bounding_coordinates: Optional[GeoBoxLocation] = Field(None, description="""The bounding coordinates of the place""") + type: Literal["EnvironmentalSite"] = Field("EnvironmentalSite", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + + +# Update forward refs +# see https://pydantic-docs.helpmanual.io/usage/postponed_annotations/ +Identified.update_forward_refs() +Typed.update_forward_refs() +Entity.update_forward_refs() +NamedThing.update_forward_refs() +Concept.update_forward_refs() +InformationEntity.update_forward_refs() +PhysicalDevice.update_forward_refs() +Intangible.update_forward_refs() +StructuredValue.update_forward_refs() +Role.update_forward_refs() +Relationship.update_forward_refs() +Location.update_forward_refs() +PointLocation.update_forward_refs() +Observation.update_forward_refs() +Specification.update_forward_refs() +Procedure.update_forward_refs() +Collection.update_forward_refs() +QuantityKind.update_forward_refs() +Quantity.update_forward_refs() +SimpleQuantity.update_forward_refs() +Ratio.update_forward_refs() +QuantityRange.update_forward_refs() +UnitConcept.update_forward_refs() +Place.update_forward_refs() +Landform.update_forward_refs() +PostalAddress.update_forward_refs() +GeoPointLocation.update_forward_refs() +GeoBoxLocation.update_forward_refs() +EnvironmentalSite.update_forward_refs() + diff --git a/src/linkml_common/datamodel/extractiveindustry.py b/src/linkml_common/datamodel/extractiveindustry.py new file mode 100644 index 0000000..c8ece6f --- /dev/null +++ b/src/linkml_common/datamodel/extractiveindustry.py @@ -0,0 +1,870 @@ +from __future__ import annotations +from datetime import ( + datetime, + date +) +from decimal import Decimal +from enum import Enum +import re +import sys +from typing import ( + Any, + List, + Literal, + Dict, + Optional, + Union +) +from pydantic.version import VERSION as PYDANTIC_VERSION +if int(PYDANTIC_VERSION[0])>=2: + from pydantic import ( + BaseModel, + ConfigDict, + Field, + field_validator + ) +else: + from pydantic import ( + BaseModel, + Field, + validator + ) + +metamodel_version = "None" +version = "None" + + +class WeakRefShimBaseModel(BaseModel): + __slots__ = '__weakref__' + +class ConfiguredBaseModel(WeakRefShimBaseModel, + validate_assignment = True, + validate_all = True, + underscore_attrs_are_private = True, + extra = "forbid", + arbitrary_types_allowed = True, + use_enum_values = True): + pass + + +class RelativeTimeEnum(str, Enum): + BEFORE = "BEFORE" + AFTER = "AFTER" + AT_SAME_TIME_AS = "AT_SAME_TIME_AS" + + +class HumanLanguageCodeEnum(str): + """ + An enumeration of languages + """ + pass + + +class PersonStatus(str, Enum): + # the person is living + ALIVE = "ALIVE" + # the person is deceased + DEAD = "DEAD" + # the vital status is not known + UNKNOWN = "UNKNOWN" + + +class ExtractiveIndustryFacilityType(str, Enum): + # A facility where mineral resources are extracted + MINING_FACILITY = "MINING_FACILITY" + # A facility where fluid resources are extracted + WELL_FACILITY = "WELL_FACILITY" + # A facility where stone, sand, or gravel are extracted + QUARRY_FACILITY = "QUARRY_FACILITY" + + +class ExtractiveIndustryProductType(str, Enum): + # A solid inorganic substance + MINERAL = "MINERAL" + # A solid metallic substance + METAL = "METAL" + # A combustible black or brownish-black sedimentary rock + COAL = "COAL" + # A liquid petroleum resource + OIL = "OIL" + # A gaseous petroleum resource + GAS = "GAS" + # A solid aggregate of minerals + STONE = "STONE" + # A granular material composed of finely divided rock and mineral particles + SAND = "SAND" + # A loose aggregation of rock fragments + GRAVEL = "GRAVEL" + + +class MiningMethod(str, Enum): + # Extraction occurs beneath the earth's surface + UNDERGROUND = "UNDERGROUND" + # Extraction occurs on the earth's surface + OPEN_PIT = "OPEN_PIT" + # Extraction of valuable minerals from alluvial deposits + PLACER = "PLACER" + # Extraction without removing the ore from its original location + IN_SITU = "IN_SITU" + + +class WellType(str, Enum): + # A well that primarily extracts crude oil + OIL = "OIL" + # A well that primarily extracts natural gas + GAS = "GAS" + # A well that extracts water for various purposes + WATER = "WATER" + # A well used to inject fluids into underground formations + INJECTION = "INJECTION" + + +class Entity(ConfiguredBaseModel): + """ + A physical, digital, conceptual, or other kind of thing with some common characteristics + """ + type: Literal["Entity"] = Field("Entity", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Variable(Entity): + allowed_units: Optional[List[str]] = Field(default_factory=list, description="""The units that are allowed for this variable""") + type: Literal["Variable"] = Field("Variable", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class PostalAddress(Entity): + """ + Represents an Address + """ + street_address: Optional[str] = Field(None, description="""The street address""") + street_address_additional: Optional[str] = Field(None) + city: Optional[str] = Field(None, description="""The city""") + state: Optional[str] = Field(None, description="""The state""") + postal_code: Optional[str] = Field(None, description="""The postal code or zip code""") + country: Optional[str] = Field(None, description="""The country""") + type: Literal["PostalAddress"] = Field("PostalAddress", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class NamedThing(Entity): + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["NamedThing"] = Field("NamedThing", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + +class Place(NamedThing): + """ + Entities that have a somewhat fixed, physical extension. + """ + address: Optional[PostalAddress] = Field(None) + geolocation: Optional[GeoPointLocation] = Field(None, description="""The geolocation of the place""") + bounding_coordinates: Optional[GeoBoxLocation] = Field(None, description="""The bounding coordinates of the place""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Place"] = Field("Place", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + +class Landform(Place): + """ + A natural feature of the solid surface of the Earth or other planetary body + """ + address: Optional[PostalAddress] = Field(None) + geolocation: Optional[GeoPointLocation] = Field(None, description="""The geolocation of the place""") + bounding_coordinates: Optional[GeoBoxLocation] = Field(None, description="""The bounding coordinates of the place""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Landform"] = Field("Landform", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + +class RawMaterial(NamedThing): + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["RawMaterial"] = Field("RawMaterial", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + +class Equipment(NamedThing): + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Equipment"] = Field("Equipment", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + +class Concept(NamedThing): + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Concept"] = Field("Concept", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + +class InformationEntity(NamedThing): + """ + An entity that describes some information + """ + describes: Optional[Any] = Field(None, description="""The thing that is being described""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["InformationEntity"] = Field("InformationEntity", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + +class PhysicalDevice(NamedThing): + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["PhysicalDevice"] = Field("PhysicalDevice", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + +class Intangible(Entity): + """ + An entity that is not a physical object, process, or information + """ + type: Literal["Intangible"] = Field("Intangible", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Role(Intangible): + type: Literal["Role"] = Field("Role", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Relationship(Intangible): + type: Literal["Relationship"] = Field("Relationship", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Location(ConfiguredBaseModel): + pass + + +class GeoBoxLocation(Location): + west_bounding_coordinate: Optional[Decimal] = Field(None, description="""The westernmost coordinate of the location""") + east_bounding_coordinate: Optional[Decimal] = Field(None, description="""The easternmost coordinate of the location""") + north_bounding_coordinate: Optional[Decimal] = Field(None, description="""The northernmost coordinate of the location""") + south_bounding_coordinate: Optional[Decimal] = Field(None, description="""The southernmost coordinate of the location""") + + +class PointLocation(Location): + pass + + +class GeoPointLocation(PointLocation): + latitude: Optional[Decimal] = Field(None, description="""The latitude of the location""") + longitude: Optional[Decimal] = Field(None, description="""The longitude of the location""") + altitude: Optional[Decimal] = Field(None, description="""The altitude of the location""") + + +class Observation(Entity): + """ + A statement about the state of something + """ + type: Literal["Observation"] = Field("Observation", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Measurement(Observation): + quantity_measured: Optional[Union[Quantity,SimpleQuantity,Ratio,Duration]] = Field(None, description="""The quantity being measured""") + variable_measured: Optional[Variable] = Field(None, description="""The variable being measured""") + type: Literal["Measurement"] = Field("Measurement", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Specification(NamedThing): + """ + A specification of a thing + """ + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Specification"] = Field("Specification", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + +class Procedure(Specification): + """ + A canonical series of actions conducted in a certain order or manner + """ + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Procedure"] = Field("Procedure", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + +class EngineeringSpecification(Procedure): + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["EngineeringSpecification"] = Field("EngineeringSpecification", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + +class MathematicalOperation(ConfiguredBaseModel): + """ + Application of a mathematical operation to one or more inputs to produce one or more outputs + """ + inputs: Optional[List[Any]] = Field(default_factory=list, description="""The inputs to the operation""") + outputs: Optional[List[Any]] = Field(default_factory=list, description="""The outputs of the operation""") + parts: Optional[List[MathematicalOperation]] = Field(default_factory=list, description="""The parts of the process""") + immediate_preceding_steps: Optional[List[MathematicalOperation]] = Field(default_factory=list, description="""The steps that immediately precede this step""") + + +class Collection(Intangible): + """ + A group of things. The collection may be heterogeneous or homogeneous. + """ + members: Optional[List[Union[Entity,Variable,PostalAddress,NamedThing,Intangible,Observation,Measurement,Role,Relationship,Collection,Quantity,QuantityRange,TimePointOrTemporalInterval,Service,TemporalInterval,TimePoint,SimpleQuantity,Ratio,Duration,TemporalRelationship,Place,RawMaterial,Equipment,Concept,InformationEntity,PhysicalDevice,Specification,Event,BuiltEnvironmentFeature,Agent,CreativeWork,Person,Organization,AutomatedAgent,Facility,BuiltSystem,Building,ExtractiveIndustryFacility,MiningFacility,WellFacility,QuarryFacility,EngineeringProcess,PlannedProcess,LifeEvent,MaterialCollection,MaterialProcessing,EngineeringMaterialProcessing,Procedure,EngineeringSpecification,QuantityKind,UnitConcept,ExtractiveIndustryProduct,ExtractiveIndustryWaste,ExtractiveIndustryEquipment,Landform]]] = Field(default_factory=list, description="""The members of the collection""") + type: Literal["Collection"] = Field("Collection", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class QuantityKind(Concept): + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["QuantityKind"] = Field("QuantityKind", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + +class Quantity(Intangible): + has_quantity_kind: Optional[str] = Field(None, description="""The kind of quantity""") + type: Literal["Quantity"] = Field("Quantity", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class SimpleQuantity(Quantity): + """ + A quantity is a property that can be measured or counted + """ + value: Optional[float] = Field(None, description="""The value of the quantity""") + unit: Optional[str] = Field(None) + has_quantity_kind: Optional[str] = Field(None, description="""The kind of quantity""") + type: Literal["SimpleQuantity"] = Field("SimpleQuantity", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Ratio(Quantity): + """ + A tuple of two quantities + """ + numerator: Optional[Union[Quantity,SimpleQuantity,Ratio,Duration]] = Field(None, description="""The numerator of the ratio""") + denominator: Optional[Union[Quantity,SimpleQuantity,Ratio,Duration]] = Field(None, description="""The denominator of the ratio""") + has_quantity_kind: Optional[str] = Field(None, description="""The kind of quantity""") + type: Literal["Ratio"] = Field("Ratio", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class QuantityRange(Intangible): + """ + A quantity range is a property that can be measured or counted + """ + lower_bound: Optional[Union[Quantity,SimpleQuantity,Ratio,Duration]] = Field(None, description="""The lower bound of the range""") + upper_bound: Optional[Union[Quantity,SimpleQuantity,Ratio,Duration]] = Field(None, description="""The upper bound of the range""") + type: Literal["QuantityRange"] = Field("QuantityRange", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class UnitConversionOperation(MathematicalOperation): + """ + A unit conversion operation + """ + inputs: Optional[List[Union[Quantity,SimpleQuantity,Ratio,Duration]]] = Field(default_factory=list, description="""The input unit""") + outputs: Optional[List[Union[Quantity,SimpleQuantity,Ratio,Duration]]] = Field(default_factory=list, description="""The output unit""") + parts: Optional[List[MathematicalOperation]] = Field(default_factory=list, description="""The parts of the process""") + immediate_preceding_steps: Optional[List[MathematicalOperation]] = Field(default_factory=list, description="""The steps that immediately precede this step""") + + +class UnitConcept(Concept): + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["UnitConcept"] = Field("UnitConcept", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + +class Event(NamedThing): + """ + A thing that happens + """ + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + happens_at: Optional[TimePoint] = Field(None) + has_interval: Optional[TemporalInterval] = Field(None) + has_duration: Optional[Duration] = Field(None) + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Event"] = Field("Event", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + +class EngineeringProcess(Event): + follows_procedure: Optional[str] = Field(None) + part_of: Optional[str] = Field(None) + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + happens_at: Optional[TimePoint] = Field(None) + has_interval: Optional[TemporalInterval] = Field(None) + has_duration: Optional[Duration] = Field(None) + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["EngineeringProcess"] = Field("EngineeringProcess", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + +class TimePointOrTemporalInterval(Intangible): + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + type: Literal["TimePointOrTemporalInterval"] = Field("TimePointOrTemporalInterval", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class TemporalInterval(TimePointOrTemporalInterval): + """ + A period of time + """ + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + type: Literal["TemporalInterval"] = Field("TemporalInterval", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class TimePoint(TimePointOrTemporalInterval): + """ + A point in time. Can be fully specified, or specified in relative terms. + """ + year_value: Optional[int] = Field(None) + date_value: Optional[date] = Field(None) + time_value: Optional[str] = Field(None) + datetime_value: Optional[datetime ] = Field(None) + marker_event: Optional[str] = Field(None) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + type: Literal["TimePoint"] = Field("TimePoint", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Duration(Quantity): + """ + A length of time + """ + has_quantity_kind: Optional[str] = Field(None, description="""The kind of quantity""") + type: Literal["Duration"] = Field("Duration", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class TemporalRelationship(Relationship): + """ + A relationship to another time point + """ + predicate: Optional[RelativeTimeEnum] = Field(None, description="""The relationship between the two time points""") + relative_to: Optional[Union[TemporalInterval, TimePoint, str]] = Field(None) + type: Literal["TemporalRelationship"] = Field("TemporalRelationship", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class PlannedProcess(Event): + """ + A process that follows a defined procedure or plan + """ + follows_procedure: Optional[str] = Field(None) + uses_physical_device: Optional[str] = Field(None) + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + happens_at: Optional[TimePoint] = Field(None) + has_interval: Optional[TemporalInterval] = Field(None) + has_duration: Optional[Duration] = Field(None) + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["PlannedProcess"] = Field("PlannedProcess", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + +class MaterialCollection(PlannedProcess): + follows_procedure: Optional[str] = Field(None) + uses_physical_device: Optional[str] = Field(None) + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + happens_at: Optional[TimePoint] = Field(None) + has_interval: Optional[TemporalInterval] = Field(None) + has_duration: Optional[Duration] = Field(None) + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["MaterialCollection"] = Field("MaterialCollection", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + +class MaterialProcessing(PlannedProcess): + follows_procedure: Optional[str] = Field(None) + uses_physical_device: Optional[str] = Field(None) + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + happens_at: Optional[TimePoint] = Field(None) + has_interval: Optional[TemporalInterval] = Field(None) + has_duration: Optional[Duration] = Field(None) + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["MaterialProcessing"] = Field("MaterialProcessing", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + +class EngineeringMaterialProcessing(MaterialProcessing): + follows_procedure: Optional[str] = Field(None) + uses_physical_device: Optional[str] = Field(None) + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + happens_at: Optional[TimePoint] = Field(None) + has_interval: Optional[TemporalInterval] = Field(None) + has_duration: Optional[Duration] = Field(None) + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["EngineeringMaterialProcessing"] = Field("EngineeringMaterialProcessing", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + +class BuiltEnvironmentFeature(NamedThing): + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["BuiltEnvironmentFeature"] = Field("BuiltEnvironmentFeature", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + +class Facility(BuiltEnvironmentFeature): + located_at_place: Optional[str] = Field(None, description="""The place where the entity is located""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Facility"] = Field("Facility", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + +class Building(Facility): + located_at_place: Optional[str] = Field(None, description="""The place where the entity is located""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Building"] = Field("Building", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + +class BuiltSystem(BuiltEnvironmentFeature): + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["BuiltSystem"] = Field("BuiltSystem", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + +class Agent(NamedThing): + """ + Represents an Agent + """ + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Agent"] = Field("Agent", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + +class Person(Agent): + """ + Represents a Person + """ + primary_email: Optional[str] = Field(None, description="""The main email address of a person""") + birth_date: Optional[date] = Field(None, description="""Date on which a person is born""") + age_in_years: Optional[int] = Field(None, description="""Number of years since birth""") + vital_status: Optional[PersonStatus] = Field(None, description="""living or dead status""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Person"] = Field("Person", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + @validator('primary_email', allow_reuse=True) + def pattern_primary_email(cls, v): + pattern=re.compile(r"^\S+@[\S+\.]+\S+") + if isinstance(v,list): + for element in v: + if not pattern.match(element): + raise ValueError(f"Invalid primary_email format: {element}") + elif isinstance(v,str): + if not pattern.match(v): + raise ValueError(f"Invalid primary_email format: {v}") + return v + + +class Organization(Agent): + """ + Represents an Organization + """ + provides_services: Optional[List[Service]] = Field(default_factory=list) + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Organization"] = Field("Organization", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + +class AutomatedAgent(Agent): + """ + Represents an Automated Agent + """ + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["AutomatedAgent"] = Field("AutomatedAgent", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + +class LifeEvent(Event): + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + happens_at: Optional[TimePoint] = Field(None) + has_interval: Optional[TemporalInterval] = Field(None) + has_duration: Optional[Duration] = Field(None) + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["LifeEvent"] = Field("LifeEvent", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + +class CreativeWork(NamedThing): + """ + The most generic kind of creative work, including books, movies, photographs, software programs, etc. + """ + title: Optional[str] = Field(None, description="""The title of the item""") + abstract: Optional[str] = Field(None, description="""A summary of the item""") + rights: Optional[str] = Field(None, description="""Information about rights held in and over the item""") + creators: Optional[List[str]] = Field(default_factory=list, description="""The person or organization who created the work""") + contributors: Optional[List[str]] = Field(default_factory=list, description="""A person or organization that contributed to the creation of the work""") + contacts: Optional[List[str]] = Field(default_factory=list, description="""A contact point for a person or organization""") + keywords: Optional[List[str]] = Field(default_factory=list, description="""Keywords or tags used to describe this item""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["CreativeWork"] = Field("CreativeWork", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + +class Service(Intangible): + """ + A service provided by an organization + """ + type: Literal["Service"] = Field("Service", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class ExtractiveIndustryFacility(Facility): + """ + A facility where natural resources are extracted from the earth + """ + facility_type: Optional[ExtractiveIndustryFacilityType] = Field(None) + operator: Optional[str] = Field(None) + products: Optional[List[ExtractiveIndustryProduct]] = Field(default_factory=list) + production_capacity: Optional[SimpleQuantity] = Field(None) + annual_production: Optional[SimpleQuantity] = Field(None) + reserves: Optional[SimpleQuantity] = Field(None) + located_at_place: Optional[str] = Field(None, description="""The place where the entity is located""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["ExtractiveIndustryFacility"] = Field("ExtractiveIndustryFacility", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + +class MiningFacility(ExtractiveIndustryFacility): + """ + A facility where mineral resources are extracted from the earth + """ + mining_method: Optional[MiningMethod] = Field(None) + depth: Optional[SimpleQuantity] = Field(None) + area: Optional[SimpleQuantity] = Field(None) + facility_type: Optional[ExtractiveIndustryFacilityType] = Field(None) + operator: Optional[str] = Field(None) + products: Optional[List[ExtractiveIndustryProduct]] = Field(default_factory=list) + production_capacity: Optional[SimpleQuantity] = Field(None) + annual_production: Optional[SimpleQuantity] = Field(None) + reserves: Optional[SimpleQuantity] = Field(None) + located_at_place: Optional[str] = Field(None, description="""The place where the entity is located""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["MiningFacility"] = Field("MiningFacility", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + +class WellFacility(ExtractiveIndustryFacility): + """ + A facility where fluid resources (e.g., oil, gas, water) are extracted from the earth + """ + well_type: Optional[WellType] = Field(None) + depth: Optional[SimpleQuantity] = Field(None) + facility_type: Optional[ExtractiveIndustryFacilityType] = Field(None) + operator: Optional[str] = Field(None) + products: Optional[List[ExtractiveIndustryProduct]] = Field(default_factory=list) + production_capacity: Optional[SimpleQuantity] = Field(None) + annual_production: Optional[SimpleQuantity] = Field(None) + reserves: Optional[SimpleQuantity] = Field(None) + located_at_place: Optional[str] = Field(None, description="""The place where the entity is located""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["WellFacility"] = Field("WellFacility", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + +class QuarryFacility(ExtractiveIndustryFacility): + """ + A facility where stone, sand, or gravel are extracted from the earth + """ + facility_type: Optional[ExtractiveIndustryFacilityType] = Field(None) + operator: Optional[str] = Field(None) + products: Optional[List[ExtractiveIndustryProduct]] = Field(default_factory=list) + production_capacity: Optional[SimpleQuantity] = Field(None) + annual_production: Optional[SimpleQuantity] = Field(None) + reserves: Optional[SimpleQuantity] = Field(None) + located_at_place: Optional[str] = Field(None, description="""The place where the entity is located""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["QuarryFacility"] = Field("QuarryFacility", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + +class ExtractiveIndustryEquipment(Equipment): + """ + The equipment used in extractive industry operations + """ + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["ExtractiveIndustryEquipment"] = Field("ExtractiveIndustryEquipment", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + +class ExtractiveIndustryProduct(Concept): + """ + A product extracted from an extractive industry facility + """ + product_type: Optional[ExtractiveIndustryProductType] = Field(None) + grade: Optional[SimpleQuantity] = Field(None) + processing_method: Optional[str] = Field(None) + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["ExtractiveIndustryProduct"] = Field("ExtractiveIndustryProduct", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + +class ExtractiveIndustryWaste(Concept): + """ + Waste material generated from extractive industry operations + """ + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["ExtractiveIndustryWaste"] = Field("ExtractiveIndustryWaste", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + +# Update forward refs +# see https://pydantic-docs.helpmanual.io/usage/postponed_annotations/ +Entity.update_forward_refs() +Variable.update_forward_refs() +PostalAddress.update_forward_refs() +NamedThing.update_forward_refs() +Place.update_forward_refs() +Landform.update_forward_refs() +RawMaterial.update_forward_refs() +Equipment.update_forward_refs() +Concept.update_forward_refs() +InformationEntity.update_forward_refs() +PhysicalDevice.update_forward_refs() +Intangible.update_forward_refs() +Role.update_forward_refs() +Relationship.update_forward_refs() +Location.update_forward_refs() +GeoBoxLocation.update_forward_refs() +PointLocation.update_forward_refs() +GeoPointLocation.update_forward_refs() +Observation.update_forward_refs() +Measurement.update_forward_refs() +Specification.update_forward_refs() +Procedure.update_forward_refs() +EngineeringSpecification.update_forward_refs() +MathematicalOperation.update_forward_refs() +Collection.update_forward_refs() +QuantityKind.update_forward_refs() +Quantity.update_forward_refs() +SimpleQuantity.update_forward_refs() +Ratio.update_forward_refs() +QuantityRange.update_forward_refs() +UnitConversionOperation.update_forward_refs() +UnitConcept.update_forward_refs() +Event.update_forward_refs() +EngineeringProcess.update_forward_refs() +TimePointOrTemporalInterval.update_forward_refs() +TemporalInterval.update_forward_refs() +TimePoint.update_forward_refs() +Duration.update_forward_refs() +TemporalRelationship.update_forward_refs() +PlannedProcess.update_forward_refs() +MaterialCollection.update_forward_refs() +MaterialProcessing.update_forward_refs() +EngineeringMaterialProcessing.update_forward_refs() +BuiltEnvironmentFeature.update_forward_refs() +Facility.update_forward_refs() +Building.update_forward_refs() +BuiltSystem.update_forward_refs() +Agent.update_forward_refs() +Person.update_forward_refs() +Organization.update_forward_refs() +AutomatedAgent.update_forward_refs() +LifeEvent.update_forward_refs() +CreativeWork.update_forward_refs() +Service.update_forward_refs() +ExtractiveIndustryFacility.update_forward_refs() +MiningFacility.update_forward_refs() +WellFacility.update_forward_refs() +QuarryFacility.update_forward_refs() +ExtractiveIndustryEquipment.update_forward_refs() +ExtractiveIndustryProduct.update_forward_refs() +ExtractiveIndustryWaste.update_forward_refs() + diff --git a/src/linkml_common/datamodel/financial.py b/src/linkml_common/datamodel/financial.py new file mode 100644 index 0000000..3244725 --- /dev/null +++ b/src/linkml_common/datamodel/financial.py @@ -0,0 +1,520 @@ +from __future__ import annotations +from datetime import ( + datetime, + date +) +from decimal import Decimal +from enum import Enum +import re +import sys +from typing import ( + Any, + List, + Literal, + Dict, + Optional, + Union +) +from pydantic.version import VERSION as PYDANTIC_VERSION +if int(PYDANTIC_VERSION[0])>=2: + from pydantic import ( + BaseModel, + ConfigDict, + Field, + field_validator + ) +else: + from pydantic import ( + BaseModel, + Field, + validator + ) + +metamodel_version = "None" +version = "None" + + +class WeakRefShimBaseModel(BaseModel): + __slots__ = '__weakref__' + +class ConfiguredBaseModel(WeakRefShimBaseModel, + validate_assignment = True, + validate_all = True, + underscore_attrs_are_private = True, + extra = "forbid", + arbitrary_types_allowed = True, + use_enum_values = True): + pass + + +class RelativeTimeEnum(str, Enum): + BEFORE = "BEFORE" + AFTER = "AFTER" + AT_SAME_TIME_AS = "AT_SAME_TIME_AS" + + +class HumanLanguageCodeEnum(str): + """ + An enumeration of languages + """ + pass + + +class PersonStatus(str, Enum): + # the person is living + ALIVE = "ALIVE" + # the person is deceased + DEAD = "DEAD" + # the vital status is not known + UNKNOWN = "UNKNOWN" + + +class FinanicialOrganizationEnum(str): + pass + + +class Entity(ConfiguredBaseModel): + """ + A physical, digital, conceptual, or other kind of thing with some common characteristics + """ + type: Literal["Entity"] = Field("Entity", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class NamedThing(Entity): + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["NamedThing"] = Field("NamedThing", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + +class Concept(NamedThing): + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Concept"] = Field("Concept", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + +class QuantityKind(Concept): + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["QuantityKind"] = Field("QuantityKind", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + +class UnitConcept(Concept): + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["UnitConcept"] = Field("UnitConcept", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + +class InformationEntity(NamedThing): + """ + An entity that describes some information + """ + describes: Optional[Any] = Field(None, description="""The thing that is being described""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["InformationEntity"] = Field("InformationEntity", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + +class PhysicalDevice(NamedThing): + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["PhysicalDevice"] = Field("PhysicalDevice", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + +class Intangible(Entity): + """ + An entity that is not a physical object, process, or information + """ + type: Literal["Intangible"] = Field("Intangible", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Quantity(Intangible): + has_quantity_kind: Optional[str] = Field(None, description="""The kind of quantity""") + type: Literal["Quantity"] = Field("Quantity", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class SimpleQuantity(Quantity): + """ + A quantity is a property that can be measured or counted + """ + value: Optional[float] = Field(None, description="""The value of the quantity""") + unit: Optional[str] = Field(None) + has_quantity_kind: Optional[str] = Field(None, description="""The kind of quantity""") + type: Literal["SimpleQuantity"] = Field("SimpleQuantity", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Ratio(Quantity): + """ + A tuple of two quantities + """ + numerator: Optional[Union[Quantity,SimpleQuantity,Ratio,Duration,MoneyQuantity]] = Field(None, description="""The numerator of the ratio""") + denominator: Optional[Union[Quantity,SimpleQuantity,Ratio,Duration,MoneyQuantity]] = Field(None, description="""The denominator of the ratio""") + has_quantity_kind: Optional[str] = Field(None, description="""The kind of quantity""") + type: Literal["Ratio"] = Field("Ratio", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class QuantityRange(Intangible): + """ + A quantity range is a property that can be measured or counted + """ + lower_bound: Optional[Union[Quantity,SimpleQuantity,Ratio,Duration,MoneyQuantity]] = Field(None, description="""The lower bound of the range""") + upper_bound: Optional[Union[Quantity,SimpleQuantity,Ratio,Duration,MoneyQuantity]] = Field(None, description="""The upper bound of the range""") + type: Literal["QuantityRange"] = Field("QuantityRange", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Role(Intangible): + type: Literal["Role"] = Field("Role", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Relationship(Intangible): + type: Literal["Relationship"] = Field("Relationship", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Location(ConfiguredBaseModel): + pass + + +class PointLocation(Location): + pass + + +class Observation(Entity): + """ + A statement about the state of something + """ + type: Literal["Observation"] = Field("Observation", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Specification(NamedThing): + """ + A specification of a thing + """ + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Specification"] = Field("Specification", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + +class Procedure(Specification): + """ + A canonical series of actions conducted in a certain order or manner + """ + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Procedure"] = Field("Procedure", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + +class MathematicalOperation(ConfiguredBaseModel): + """ + Application of a mathematical operation to one or more inputs to produce one or more outputs + """ + inputs: Optional[List[Any]] = Field(default_factory=list, description="""The inputs to the operation""") + outputs: Optional[List[Any]] = Field(default_factory=list, description="""The outputs of the operation""") + parts: Optional[List[MathematicalOperation]] = Field(default_factory=list, description="""The parts of the process""") + immediate_preceding_steps: Optional[List[MathematicalOperation]] = Field(default_factory=list, description="""The steps that immediately precede this step""") + + +class UnitConversionOperation(MathematicalOperation): + """ + A unit conversion operation + """ + inputs: Optional[List[Union[Quantity,SimpleQuantity,Ratio,Duration,MoneyQuantity]]] = Field(default_factory=list, description="""The input unit""") + outputs: Optional[List[Union[Quantity,SimpleQuantity,Ratio,Duration,MoneyQuantity]]] = Field(default_factory=list, description="""The output unit""") + parts: Optional[List[MathematicalOperation]] = Field(default_factory=list, description="""The parts of the process""") + immediate_preceding_steps: Optional[List[MathematicalOperation]] = Field(default_factory=list, description="""The steps that immediately precede this step""") + + +class Collection(Intangible): + """ + A group of things. The collection may be heterogeneous or homogeneous. + """ + members: Optional[List[Union[Entity,NamedThing,Intangible,Observation,Quantity,QuantityRange,Role,Relationship,Collection,TimePointOrTemporalInterval,Service,FinancialProduct,FinancialAccount,TemporalInterval,TimePoint,TemporalRelationship,SimpleQuantity,Ratio,Duration,MoneyQuantity,Concept,InformationEntity,PhysicalDevice,Specification,Event,Agent,CreativeWork,Person,Organization,AutomatedAgent,FinancialOrganization,LifeEvent,Procedure,QuantityKind,UnitConcept,CurrencyConcept]]] = Field(default_factory=list, description="""The members of the collection""") + type: Literal["Collection"] = Field("Collection", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Event(NamedThing): + """ + A thing that happens + """ + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + happens_at: Optional[TimePoint] = Field(None) + has_interval: Optional[TemporalInterval] = Field(None) + has_duration: Optional[Duration] = Field(None) + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Event"] = Field("Event", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + +class TimePointOrTemporalInterval(Intangible): + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + type: Literal["TimePointOrTemporalInterval"] = Field("TimePointOrTemporalInterval", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class TemporalInterval(TimePointOrTemporalInterval): + """ + A period of time + """ + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + type: Literal["TemporalInterval"] = Field("TemporalInterval", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class TimePoint(TimePointOrTemporalInterval): + """ + A point in time. Can be fully specified, or specified in relative terms. + """ + year_value: Optional[int] = Field(None) + date_value: Optional[date] = Field(None) + time_value: Optional[str] = Field(None) + datetime_value: Optional[datetime ] = Field(None) + marker_event: Optional[str] = Field(None) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + type: Literal["TimePoint"] = Field("TimePoint", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Duration(Quantity): + """ + A length of time + """ + has_quantity_kind: Optional[str] = Field(None, description="""The kind of quantity""") + type: Literal["Duration"] = Field("Duration", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class TemporalRelationship(Relationship): + """ + A relationship to another time point + """ + predicate: Optional[RelativeTimeEnum] = Field(None, description="""The relationship between the two time points""") + relative_to: Optional[Union[TemporalInterval, TimePoint, str]] = Field(None) + type: Literal["TemporalRelationship"] = Field("TemporalRelationship", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Agent(NamedThing): + """ + Represents an Agent + """ + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Agent"] = Field("Agent", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + +class Person(Agent): + """ + Represents a Person + """ + primary_email: Optional[str] = Field(None, description="""The main email address of a person""") + birth_date: Optional[date] = Field(None, description="""Date on which a person is born""") + age_in_years: Optional[int] = Field(None, description="""Number of years since birth""") + vital_status: Optional[PersonStatus] = Field(None, description="""living or dead status""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Person"] = Field("Person", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + @validator('primary_email', allow_reuse=True) + def pattern_primary_email(cls, v): + pattern=re.compile(r"^\S+@[\S+\.]+\S+") + if isinstance(v,list): + for element in v: + if not pattern.match(element): + raise ValueError(f"Invalid primary_email format: {element}") + elif isinstance(v,str): + if not pattern.match(v): + raise ValueError(f"Invalid primary_email format: {v}") + return v + + +class Organization(Agent): + """ + Represents an Organization + """ + provides_services: Optional[List[Union[Service,FinancialProduct,FinancialAccount]]] = Field(default_factory=list) + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Organization"] = Field("Organization", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + +class AutomatedAgent(Agent): + """ + Represents an Automated Agent + """ + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["AutomatedAgent"] = Field("AutomatedAgent", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + +class LifeEvent(Event): + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + happens_at: Optional[TimePoint] = Field(None) + has_interval: Optional[TemporalInterval] = Field(None) + has_duration: Optional[Duration] = Field(None) + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["LifeEvent"] = Field("LifeEvent", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + +class CreativeWork(NamedThing): + """ + The most generic kind of creative work, including books, movies, photographs, software programs, etc. + """ + title: Optional[str] = Field(None, description="""The title of the item""") + abstract: Optional[str] = Field(None, description="""A summary of the item""") + rights: Optional[str] = Field(None, description="""Information about rights held in and over the item""") + creators: Optional[List[str]] = Field(default_factory=list, description="""The person or organization who created the work""") + contributors: Optional[List[str]] = Field(default_factory=list, description="""A person or organization that contributed to the creation of the work""") + contacts: Optional[List[str]] = Field(default_factory=list, description="""A contact point for a person or organization""") + keywords: Optional[List[str]] = Field(default_factory=list, description="""Keywords or tags used to describe this item""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["CreativeWork"] = Field("CreativeWork", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + +class Service(Intangible): + """ + A service provided by an organization + """ + type: Literal["Service"] = Field("Service", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class MoneyQuantity(SimpleQuantity): + """ + A quantity of money + """ + value: Optional[float] = Field(None, description="""The value of the quantity""") + unit: Optional[str] = Field(None, description="""The currency of the quantity""") + has_quantity_kind: Optional[str] = Field(None, description="""The kind of quantity""") + type: Literal["MoneyQuantity"] = Field("MoneyQuantity", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class CurrencyConcept(Concept): + """ + A currency + """ + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["CurrencyConcept"] = Field("CurrencyConcept", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + +class FinancialProduct(Service): + """ + A product or service offered by a bank whereby one may deposit, withdraw or transfer money and in some cases be paid interest. + """ + type: Literal["FinancialProduct"] = Field("FinancialProduct", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class FinancialAccount(FinancialProduct): + """ + A bank account + """ + account_number: Optional[str] = Field(None, description="""The account number""") + bank: Optional[str] = Field(None, description="""The bank that holds the account""") + account_holder: Optional[str] = Field(None, description="""The person or organization that holds the account""") + type: Literal["FinancialAccount"] = Field("FinancialAccount", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class FinancialOrganization(Organization): + """ + An organization that provides financial services + """ + provides_services: Optional[List[Union[Service,FinancialProduct,FinancialAccount]]] = Field(default_factory=list) + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["FinancialOrganization"] = Field("FinancialOrganization", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + +# Update forward refs +# see https://pydantic-docs.helpmanual.io/usage/postponed_annotations/ +Entity.update_forward_refs() +NamedThing.update_forward_refs() +Concept.update_forward_refs() +QuantityKind.update_forward_refs() +UnitConcept.update_forward_refs() +InformationEntity.update_forward_refs() +PhysicalDevice.update_forward_refs() +Intangible.update_forward_refs() +Quantity.update_forward_refs() +SimpleQuantity.update_forward_refs() +Ratio.update_forward_refs() +QuantityRange.update_forward_refs() +Role.update_forward_refs() +Relationship.update_forward_refs() +Location.update_forward_refs() +PointLocation.update_forward_refs() +Observation.update_forward_refs() +Specification.update_forward_refs() +Procedure.update_forward_refs() +MathematicalOperation.update_forward_refs() +UnitConversionOperation.update_forward_refs() +Collection.update_forward_refs() +Event.update_forward_refs() +TimePointOrTemporalInterval.update_forward_refs() +TemporalInterval.update_forward_refs() +TimePoint.update_forward_refs() +Duration.update_forward_refs() +TemporalRelationship.update_forward_refs() +Agent.update_forward_refs() +Person.update_forward_refs() +Organization.update_forward_refs() +AutomatedAgent.update_forward_refs() +LifeEvent.update_forward_refs() +CreativeWork.update_forward_refs() +Service.update_forward_refs() +MoneyQuantity.update_forward_refs() +CurrencyConcept.update_forward_refs() +FinancialProduct.update_forward_refs() +FinancialAccount.update_forward_refs() +FinancialOrganization.update_forward_refs() + diff --git a/src/linkml_common/datamodel/foods.py b/src/linkml_common/datamodel/foods.py new file mode 100644 index 0000000..0eede9d --- /dev/null +++ b/src/linkml_common/datamodel/foods.py @@ -0,0 +1,591 @@ +from __future__ import annotations +from datetime import ( + datetime, + date +) +from decimal import Decimal +from enum import Enum +import re +import sys +from typing import ( + Any, + List, + Literal, + Dict, + Optional, + Union +) +from pydantic.version import VERSION as PYDANTIC_VERSION +if int(PYDANTIC_VERSION[0])>=2: + from pydantic import ( + BaseModel, + ConfigDict, + Field, + field_validator + ) +else: + from pydantic import ( + BaseModel, + Field, + validator + ) + +metamodel_version = "None" +version = "None" + + +class WeakRefShimBaseModel(BaseModel): + __slots__ = '__weakref__' + +class ConfiguredBaseModel(WeakRefShimBaseModel, + validate_assignment = True, + validate_all = True, + underscore_attrs_are_private = True, + extra = "forbid", + arbitrary_types_allowed = True, + use_enum_values = True): + pass + + +class RelativeTimeEnum(str, Enum): + BEFORE = "BEFORE" + AFTER = "AFTER" + AT_SAME_TIME_AS = "AT_SAME_TIME_AS" + + +class HumanLanguageCodeEnum(str): + """ + An enumeration of languages + """ + pass + + +class PersonStatus(str, Enum): + # the person is living + ALIVE = "ALIVE" + # the person is deceased + DEAD = "DEAD" + # the vital status is not known + UNKNOWN = "UNKNOWN" + + +class Entity(ConfiguredBaseModel): + """ + A physical, digital, conceptual, or other kind of thing with some common characteristics + """ + type: Literal["Entity"] = Field("Entity", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class NamedThing(Entity): + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["NamedThing"] = Field("NamedThing", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + +class Concept(NamedThing): + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Concept"] = Field("Concept", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + +class InformationEntity(NamedThing): + """ + An entity that describes some information + """ + describes: Optional[Any] = Field(None, description="""The thing that is being described""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["InformationEntity"] = Field("InformationEntity", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + +class PhysicalDevice(NamedThing): + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["PhysicalDevice"] = Field("PhysicalDevice", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + +class Intangible(Entity): + """ + An entity that is not a physical object, process, or information + """ + type: Literal["Intangible"] = Field("Intangible", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Role(Intangible): + type: Literal["Role"] = Field("Role", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Relationship(Intangible): + type: Literal["Relationship"] = Field("Relationship", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Location(ConfiguredBaseModel): + pass + + +class PointLocation(Location): + pass + + +class Observation(Entity): + """ + A statement about the state of something + """ + type: Literal["Observation"] = Field("Observation", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Specification(NamedThing): + """ + A specification of a thing + """ + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Specification"] = Field("Specification", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + +class Procedure(Specification): + """ + A canonical series of actions conducted in a certain order or manner + """ + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Procedure"] = Field("Procedure", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + +class MathematicalOperation(ConfiguredBaseModel): + """ + Application of a mathematical operation to one or more inputs to produce one or more outputs + """ + inputs: Optional[List[Any]] = Field(default_factory=list, description="""The inputs to the operation""") + outputs: Optional[List[Any]] = Field(default_factory=list, description="""The outputs of the operation""") + parts: Optional[List[MathematicalOperation]] = Field(default_factory=list, description="""The parts of the process""") + immediate_preceding_steps: Optional[List[MathematicalOperation]] = Field(default_factory=list, description="""The steps that immediately precede this step""") + + +class Collection(Intangible): + """ + A group of things. The collection may be heterogeneous or homogeneous. + """ + members: Optional[List[Union[Entity,NamedThing,Intangible,Observation,Variable,Measurement,Role,Relationship,Collection,TimePointOrTemporalInterval,Service,Quantity,QuantityRange,Duration,SimpleQuantity,Ratio,FoodIngredient,TemporalInterval,TimePoint,TemporalRelationship,Concept,InformationEntity,PhysicalDevice,Specification,Event,Agent,CreativeWork,Person,Organization,AutomatedAgent,LifeEvent,PlannedProcess,MaterialCollection,MaterialProcessing,FoodProcessing,Procedure,FoodRecipe,QuantityKind,UnitConcept,FoodTypeConcept,BasicFoodType,CompositeFoodType]]] = Field(default_factory=list, description="""The members of the collection""") + type: Literal["Collection"] = Field("Collection", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Event(NamedThing): + """ + A thing that happens + """ + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + happens_at: Optional[TimePoint] = Field(None) + has_interval: Optional[TemporalInterval] = Field(None) + has_duration: Optional[Duration] = Field(None) + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Event"] = Field("Event", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + +class TimePointOrTemporalInterval(Intangible): + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + type: Literal["TimePointOrTemporalInterval"] = Field("TimePointOrTemporalInterval", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class TemporalInterval(TimePointOrTemporalInterval): + """ + A period of time + """ + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + type: Literal["TemporalInterval"] = Field("TemporalInterval", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class TimePoint(TimePointOrTemporalInterval): + """ + A point in time. Can be fully specified, or specified in relative terms. + """ + year_value: Optional[int] = Field(None) + date_value: Optional[date] = Field(None) + time_value: Optional[str] = Field(None) + datetime_value: Optional[datetime ] = Field(None) + marker_event: Optional[str] = Field(None) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + type: Literal["TimePoint"] = Field("TimePoint", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class TemporalRelationship(Relationship): + """ + A relationship to another time point + """ + predicate: Optional[RelativeTimeEnum] = Field(None, description="""The relationship between the two time points""") + relative_to: Optional[Union[TemporalInterval, TimePoint, str]] = Field(None) + type: Literal["TemporalRelationship"] = Field("TemporalRelationship", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Agent(NamedThing): + """ + Represents an Agent + """ + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Agent"] = Field("Agent", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + +class Person(Agent): + """ + Represents a Person + """ + primary_email: Optional[str] = Field(None, description="""The main email address of a person""") + birth_date: Optional[date] = Field(None, description="""Date on which a person is born""") + age_in_years: Optional[int] = Field(None, description="""Number of years since birth""") + vital_status: Optional[PersonStatus] = Field(None, description="""living or dead status""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Person"] = Field("Person", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + @validator('primary_email', allow_reuse=True) + def pattern_primary_email(cls, v): + pattern=re.compile(r"^\S+@[\S+\.]+\S+") + if isinstance(v,list): + for element in v: + if not pattern.match(element): + raise ValueError(f"Invalid primary_email format: {element}") + elif isinstance(v,str): + if not pattern.match(v): + raise ValueError(f"Invalid primary_email format: {v}") + return v + + +class Organization(Agent): + """ + Represents an Organization + """ + provides_services: Optional[List[Service]] = Field(default_factory=list) + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Organization"] = Field("Organization", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + +class AutomatedAgent(Agent): + """ + Represents an Automated Agent + """ + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["AutomatedAgent"] = Field("AutomatedAgent", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + +class LifeEvent(Event): + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + happens_at: Optional[TimePoint] = Field(None) + has_interval: Optional[TemporalInterval] = Field(None) + has_duration: Optional[Duration] = Field(None) + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["LifeEvent"] = Field("LifeEvent", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + +class CreativeWork(NamedThing): + """ + The most generic kind of creative work, including books, movies, photographs, software programs, etc. + """ + title: Optional[str] = Field(None, description="""The title of the item""") + abstract: Optional[str] = Field(None, description="""A summary of the item""") + rights: Optional[str] = Field(None, description="""Information about rights held in and over the item""") + creators: Optional[List[str]] = Field(default_factory=list, description="""The person or organization who created the work""") + contributors: Optional[List[str]] = Field(default_factory=list, description="""A person or organization that contributed to the creation of the work""") + contacts: Optional[List[str]] = Field(default_factory=list, description="""A contact point for a person or organization""") + keywords: Optional[List[str]] = Field(default_factory=list, description="""Keywords or tags used to describe this item""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["CreativeWork"] = Field("CreativeWork", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + +class Service(Intangible): + """ + A service provided by an organization + """ + type: Literal["Service"] = Field("Service", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class QuantityKind(Concept): + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["QuantityKind"] = Field("QuantityKind", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + +class Quantity(Intangible): + has_quantity_kind: Optional[str] = Field(None, description="""The kind of quantity""") + type: Literal["Quantity"] = Field("Quantity", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Duration(Quantity): + """ + A length of time + """ + has_quantity_kind: Optional[str] = Field(None, description="""The kind of quantity""") + type: Literal["Duration"] = Field("Duration", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class SimpleQuantity(Quantity): + """ + A quantity is a property that can be measured or counted + """ + value: Optional[float] = Field(None, description="""The value of the quantity""") + unit: Optional[str] = Field(None) + has_quantity_kind: Optional[str] = Field(None, description="""The kind of quantity""") + type: Literal["SimpleQuantity"] = Field("SimpleQuantity", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Ratio(Quantity): + """ + A tuple of two quantities + """ + numerator: Optional[Union[Quantity,Duration,SimpleQuantity,Ratio,FoodIngredient]] = Field(None, description="""The numerator of the ratio""") + denominator: Optional[Union[Quantity,Duration,SimpleQuantity,Ratio,FoodIngredient]] = Field(None, description="""The denominator of the ratio""") + has_quantity_kind: Optional[str] = Field(None, description="""The kind of quantity""") + type: Literal["Ratio"] = Field("Ratio", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class QuantityRange(Intangible): + """ + A quantity range is a property that can be measured or counted + """ + lower_bound: Optional[Union[Quantity,Duration,SimpleQuantity,Ratio,FoodIngredient]] = Field(None, description="""The lower bound of the range""") + upper_bound: Optional[Union[Quantity,Duration,SimpleQuantity,Ratio,FoodIngredient]] = Field(None, description="""The upper bound of the range""") + type: Literal["QuantityRange"] = Field("QuantityRange", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class UnitConversionOperation(MathematicalOperation): + """ + A unit conversion operation + """ + inputs: Optional[List[Union[Quantity,Duration,SimpleQuantity,Ratio,FoodIngredient]]] = Field(default_factory=list, description="""The input unit""") + outputs: Optional[List[Union[Quantity,Duration,SimpleQuantity,Ratio,FoodIngredient]]] = Field(default_factory=list, description="""The output unit""") + parts: Optional[List[MathematicalOperation]] = Field(default_factory=list, description="""The parts of the process""") + immediate_preceding_steps: Optional[List[MathematicalOperation]] = Field(default_factory=list, description="""The steps that immediately precede this step""") + + +class UnitConcept(Concept): + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["UnitConcept"] = Field("UnitConcept", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + +class Measurement(Observation): + quantity_measured: Optional[Union[Quantity,Duration,SimpleQuantity,Ratio,FoodIngredient]] = Field(None, description="""The quantity being measured""") + variable_measured: Optional[Variable] = Field(None, description="""The variable being measured""") + type: Literal["Measurement"] = Field("Measurement", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Variable(Entity): + allowed_units: Optional[List[str]] = Field(default_factory=list, description="""The units that are allowed for this variable""") + type: Literal["Variable"] = Field("Variable", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class PlannedProcess(Event): + """ + A process that follows a defined procedure or plan + """ + follows_procedure: Optional[str] = Field(None) + uses_physical_device: Optional[str] = Field(None) + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + happens_at: Optional[TimePoint] = Field(None) + has_interval: Optional[TemporalInterval] = Field(None) + has_duration: Optional[Duration] = Field(None) + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["PlannedProcess"] = Field("PlannedProcess", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + +class MaterialCollection(PlannedProcess): + follows_procedure: Optional[str] = Field(None) + uses_physical_device: Optional[str] = Field(None) + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + happens_at: Optional[TimePoint] = Field(None) + has_interval: Optional[TemporalInterval] = Field(None) + has_duration: Optional[Duration] = Field(None) + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["MaterialCollection"] = Field("MaterialCollection", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + +class MaterialProcessing(PlannedProcess): + follows_procedure: Optional[str] = Field(None) + uses_physical_device: Optional[str] = Field(None) + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + happens_at: Optional[TimePoint] = Field(None) + has_interval: Optional[TemporalInterval] = Field(None) + has_duration: Optional[Duration] = Field(None) + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["MaterialProcessing"] = Field("MaterialProcessing", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + +class FoodRecipe(Procedure): + ingredients: Optional[List[FoodIngredient]] = Field(default_factory=list) + steps: Optional[List[str]] = Field(default_factory=list) + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["FoodRecipe"] = Field("FoodRecipe", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + +class FoodIngredient(Quantity): + has_quantity_kind: Optional[str] = Field(None, description="""The kind of quantity""") + type: Literal["FoodIngredient"] = Field("FoodIngredient", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class FoodProcessing(MaterialProcessing): + follows_procedure: Optional[str] = Field(None) + uses_physical_device: Optional[str] = Field(None) + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + happens_at: Optional[TimePoint] = Field(None) + has_interval: Optional[TemporalInterval] = Field(None) + has_duration: Optional[Duration] = Field(None) + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["FoodProcessing"] = Field("FoodProcessing", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + +class FoodTypeConcept(Concept): + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["FoodTypeConcept"] = Field("FoodTypeConcept", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + +class BasicFoodType(FoodTypeConcept): + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["BasicFoodType"] = Field("BasicFoodType", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + +class CompositeFoodType(FoodTypeConcept): + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["CompositeFoodType"] = Field("CompositeFoodType", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + +# Update forward refs +# see https://pydantic-docs.helpmanual.io/usage/postponed_annotations/ +Entity.update_forward_refs() +NamedThing.update_forward_refs() +Concept.update_forward_refs() +InformationEntity.update_forward_refs() +PhysicalDevice.update_forward_refs() +Intangible.update_forward_refs() +Role.update_forward_refs() +Relationship.update_forward_refs() +Location.update_forward_refs() +PointLocation.update_forward_refs() +Observation.update_forward_refs() +Specification.update_forward_refs() +Procedure.update_forward_refs() +MathematicalOperation.update_forward_refs() +Collection.update_forward_refs() +Event.update_forward_refs() +TimePointOrTemporalInterval.update_forward_refs() +TemporalInterval.update_forward_refs() +TimePoint.update_forward_refs() +TemporalRelationship.update_forward_refs() +Agent.update_forward_refs() +Person.update_forward_refs() +Organization.update_forward_refs() +AutomatedAgent.update_forward_refs() +LifeEvent.update_forward_refs() +CreativeWork.update_forward_refs() +Service.update_forward_refs() +QuantityKind.update_forward_refs() +Quantity.update_forward_refs() +Duration.update_forward_refs() +SimpleQuantity.update_forward_refs() +Ratio.update_forward_refs() +QuantityRange.update_forward_refs() +UnitConversionOperation.update_forward_refs() +UnitConcept.update_forward_refs() +Measurement.update_forward_refs() +Variable.update_forward_refs() +PlannedProcess.update_forward_refs() +MaterialCollection.update_forward_refs() +MaterialProcessing.update_forward_refs() +FoodRecipe.update_forward_refs() +FoodIngredient.update_forward_refs() +FoodProcessing.update_forward_refs() +FoodTypeConcept.update_forward_refs() +BasicFoodType.update_forward_refs() +CompositeFoodType.update_forward_refs() + diff --git a/src/linkml_common/datamodel/geography.py b/src/linkml_common/datamodel/geography.py new file mode 100644 index 0000000..fb8fc89 --- /dev/null +++ b/src/linkml_common/datamodel/geography.py @@ -0,0 +1,332 @@ +from __future__ import annotations +from datetime import ( + datetime, + date +) +from decimal import Decimal +from enum import Enum +import re +import sys +from typing import ( + Any, + List, + Literal, + Dict, + Optional, + Union +) +from pydantic.version import VERSION as PYDANTIC_VERSION +if int(PYDANTIC_VERSION[0])>=2: + from pydantic import ( + BaseModel, + ConfigDict, + Field, + field_validator + ) +else: + from pydantic import ( + BaseModel, + Field, + validator + ) + +metamodel_version = "None" +version = "None" + + +class WeakRefShimBaseModel(BaseModel): + __slots__ = '__weakref__' + +class ConfiguredBaseModel(WeakRefShimBaseModel, + validate_assignment = True, + validate_all = True, + underscore_attrs_are_private = True, + extra = "forbid", + arbitrary_types_allowed = True, + use_enum_values = True): + pass + + +class Entity(ConfiguredBaseModel): + """ + A physical, digital, conceptual, or other kind of thing with some common characteristics + """ + type: Literal["Entity"] = Field("Entity", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Identified(ConfiguredBaseModel): + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + + +class NamedThing(Identified, Entity): + type: Literal["NamedThing"] = Field("NamedThing", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + + +class Concept(NamedThing): + type: Literal["Concept"] = Field("Concept", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + + +class InformationEntity(NamedThing): + """ + An entity that describes some information + """ + describes: Optional[Any] = Field(None, description="""The thing that is being described""") + type: Literal["InformationEntity"] = Field("InformationEntity", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + + +class PhysicalDevice(NamedThing): + type: Literal["PhysicalDevice"] = Field("PhysicalDevice", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + + +class Intangible(Entity): + """ + An entity that is not a physical object, process, or information + """ + type: Literal["Intangible"] = Field("Intangible", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class StructuredValue(Intangible): + """ + A value that is a structured collection of other values + """ + type: Literal["StructuredValue"] = Field("StructuredValue", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Role(Intangible): + type: Literal["Role"] = Field("Role", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Relationship(Intangible): + type: Literal["Relationship"] = Field("Relationship", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Location(StructuredValue): + type: Literal["Location"] = Field("Location", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class PointLocation(Location): + type: Literal["PointLocation"] = Field("PointLocation", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Observation(Entity): + """ + A statement about the state of something + """ + type: Literal["Observation"] = Field("Observation", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Specification(NamedThing): + """ + A specification of a thing + """ + type: Literal["Specification"] = Field("Specification", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + + +class Procedure(Specification): + """ + A canonical series of actions conducted in a certain order or manner + """ + type: Literal["Procedure"] = Field("Procedure", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + + +class MathematicalOperation(ConfiguredBaseModel): + """ + Application of a mathematical operation to one or more inputs to produce one or more outputs + """ + inputs: Optional[List[Any]] = Field(default_factory=list, description="""The inputs to the operation""") + outputs: Optional[List[Any]] = Field(default_factory=list, description="""The outputs of the operation""") + parts: Optional[List[MathematicalOperation]] = Field(default_factory=list, description="""The parts of the process""") + immediate_preceding_steps: Optional[List[MathematicalOperation]] = Field(default_factory=list, description="""The steps that immediately precede this step""") + + +class Collection(Intangible): + """ + A group of things. The collection may be heterogeneous or homogeneous. + """ + members: Optional[List[Union[Entity,NamedThing,Intangible,Observation,StructuredValue,Role,Relationship,Collection,Quantity,QuantityRange,SimpleQuantity,Ratio,Location,PostalAddress,PointLocation,GeoBoxLocation,GeoPointLocation,Concept,InformationEntity,PhysicalDevice,Specification,Place,Landform,Procedure,QuantityKind,UnitConcept]]] = Field(default_factory=list, description="""The members of the collection""") + type: Literal["Collection"] = Field("Collection", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class QuantityKind(Concept): + type: Literal["QuantityKind"] = Field("QuantityKind", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + + +class Quantity(Intangible): + has_quantity_kind: Optional[str] = Field(None, description="""The kind of quantity""") + type: Literal["Quantity"] = Field("Quantity", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class SimpleQuantity(Quantity): + """ + A quantity is a property that can be measured or counted + """ + value: Optional[float] = Field(None, description="""The value of the quantity""") + unit: Optional[str] = Field(None) + has_quantity_kind: Optional[str] = Field(None, description="""The kind of quantity""") + type: Literal["SimpleQuantity"] = Field("SimpleQuantity", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Ratio(Quantity): + """ + A tuple of two quantities + """ + numerator: Optional[Union[Quantity,SimpleQuantity,Ratio]] = Field(None, description="""The numerator of the ratio""") + denominator: Optional[Union[Quantity,SimpleQuantity,Ratio]] = Field(None, description="""The denominator of the ratio""") + has_quantity_kind: Optional[str] = Field(None, description="""The kind of quantity""") + type: Literal["Ratio"] = Field("Ratio", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class QuantityRange(Intangible): + """ + A quantity range is a property that can be measured or counted + """ + lower_bound: Optional[Union[Quantity,SimpleQuantity,Ratio]] = Field(None, description="""The lower bound of the range""") + upper_bound: Optional[Union[Quantity,SimpleQuantity,Ratio]] = Field(None, description="""The upper bound of the range""") + type: Literal["QuantityRange"] = Field("QuantityRange", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class UnitConversionOperation(MathematicalOperation): + """ + A unit conversion operation + """ + inputs: Optional[List[Union[Quantity,SimpleQuantity,Ratio]]] = Field(default_factory=list, description="""The input unit""") + outputs: Optional[List[Union[Quantity,SimpleQuantity,Ratio]]] = Field(default_factory=list, description="""The output unit""") + parts: Optional[List[MathematicalOperation]] = Field(default_factory=list, description="""The parts of the process""") + immediate_preceding_steps: Optional[List[MathematicalOperation]] = Field(default_factory=list, description="""The steps that immediately precede this step""") + + +class UnitConcept(Concept): + type: Literal["UnitConcept"] = Field("UnitConcept", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + + +class Place(NamedThing): + """ + Entities that have a somewhat fixed, physical extension. + """ + address: Optional[PostalAddress] = Field(None) + geolocation: Optional[GeoPointLocation] = Field(None, description="""The geolocation of the place""") + bounding_coordinates: Optional[GeoBoxLocation] = Field(None, description="""The bounding coordinates of the place""") + type: Literal["Place"] = Field("Place", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + + +class Landform(Place): + """ + A natural feature of the solid surface of the Earth or other planetary body + """ + address: Optional[PostalAddress] = Field(None) + geolocation: Optional[GeoPointLocation] = Field(None, description="""The geolocation of the place""") + bounding_coordinates: Optional[GeoBoxLocation] = Field(None, description="""The bounding coordinates of the place""") + type: Literal["Landform"] = Field("Landform", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + + +class PostalAddress(StructuredValue): + """ + Represents an Address + """ + street_address: Optional[str] = Field(None, description="""The street address""") + street_address_additional: Optional[str] = Field(None) + city: Optional[str] = Field(None, description="""The city""") + state: Optional[str] = Field(None, description="""The state""") + postal_code: Optional[str] = Field(None, description="""The postal code or zip code""") + country: Optional[str] = Field(None, description="""The country""") + type: Literal["PostalAddress"] = Field("PostalAddress", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class GeoPointLocation(PointLocation): + latitude: Optional[Decimal] = Field(None, description="""The latitude of the location""") + longitude: Optional[Decimal] = Field(None, description="""The longitude of the location""") + altitude: Optional[Decimal] = Field(None, description="""The altitude of the location""") + type: Literal["GeoPointLocation"] = Field("GeoPointLocation", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class GeoBoxLocation(Location): + west_bounding_coordinate: Optional[Decimal] = Field(None, description="""The westernmost coordinate of the location""") + east_bounding_coordinate: Optional[Decimal] = Field(None, description="""The easternmost coordinate of the location""") + north_bounding_coordinate: Optional[Decimal] = Field(None, description="""The northernmost coordinate of the location""") + south_bounding_coordinate: Optional[Decimal] = Field(None, description="""The southernmost coordinate of the location""") + type: Literal["GeoBoxLocation"] = Field("GeoBoxLocation", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +# Update forward refs +# see https://pydantic-docs.helpmanual.io/usage/postponed_annotations/ +Entity.update_forward_refs() +Identified.update_forward_refs() +NamedThing.update_forward_refs() +Concept.update_forward_refs() +InformationEntity.update_forward_refs() +PhysicalDevice.update_forward_refs() +Intangible.update_forward_refs() +StructuredValue.update_forward_refs() +Role.update_forward_refs() +Relationship.update_forward_refs() +Location.update_forward_refs() +PointLocation.update_forward_refs() +Observation.update_forward_refs() +Specification.update_forward_refs() +Procedure.update_forward_refs() +MathematicalOperation.update_forward_refs() +Collection.update_forward_refs() +QuantityKind.update_forward_refs() +Quantity.update_forward_refs() +SimpleQuantity.update_forward_refs() +Ratio.update_forward_refs() +QuantityRange.update_forward_refs() +UnitConversionOperation.update_forward_refs() +UnitConcept.update_forward_refs() +Place.update_forward_refs() +Landform.update_forward_refs() +PostalAddress.update_forward_refs() +GeoPointLocation.update_forward_refs() +GeoBoxLocation.update_forward_refs() + diff --git a/src/linkml_common/datamodel/healthcare.py b/src/linkml_common/datamodel/healthcare.py new file mode 100644 index 0000000..5aef2a1 --- /dev/null +++ b/src/linkml_common/datamodel/healthcare.py @@ -0,0 +1,629 @@ +from __future__ import annotations +from datetime import ( + datetime, + date +) +from decimal import Decimal +from enum import Enum +import re +import sys +from typing import ( + Any, + List, + Literal, + Dict, + Optional, + Union +) +from pydantic.version import VERSION as PYDANTIC_VERSION +if int(PYDANTIC_VERSION[0])>=2: + from pydantic import ( + BaseModel, + ConfigDict, + Field, + field_validator + ) +else: + from pydantic import ( + BaseModel, + Field, + validator + ) + +metamodel_version = "None" +version = "None" + + +class WeakRefShimBaseModel(BaseModel): + __slots__ = '__weakref__' + +class ConfiguredBaseModel(WeakRefShimBaseModel, + validate_assignment = True, + validate_all = True, + underscore_attrs_are_private = True, + extra = "forbid", + arbitrary_types_allowed = True, + use_enum_values = True): + pass + + +class RelativeTimeEnum(str, Enum): + BEFORE = "BEFORE" + AFTER = "AFTER" + AT_SAME_TIME_AS = "AT_SAME_TIME_AS" + + +class HumanLanguageCodeEnum(str): + """ + An enumeration of languages + """ + pass + + +class PersonStatus(str, Enum): + # the person is living + ALIVE = "ALIVE" + # the person is deceased + DEAD = "DEAD" + # the vital status is not known + UNKNOWN = "UNKNOWN" + + +class HealthcareEncounterClassification(str, Enum): + # Person visiting hospital, at a Care Site, in bed, for duration of more than one day, with physicians and other Providers permanently available to deliver service around the clock + Inpatient_Visit = "Inpatient Visit" + # Person visiting dedicated healthcare institution for treating emergencies, at a Care Site, within one day, with physicians and Providers permanently available to deliver service around the clock + Emergency_Room_Visit = "Emergency Room Visit" + # Person visiting ER followed by a subsequent Inpatient Visit, where Emergency department is part of hospital, and transition from the ER to other hospital departments is undefined + Emergency_Room_and_Inpatient_Visit = "Emergency Room and Inpatient Visit" + # Person visiting dedicated institution for reasons of poor health, at a Care Site, long-term or permanently, with no physician but possibly other Providers permanently available to deliver service around the clock + Non_hospital_institution_Visit = "Non-hospital institution Visit" + # Person visiting dedicated ambulatory healthcare institution, at a Care Site, within one day, without bed, with physicians or medical Providers delivering service during Visit + Outpatient_Visit = "Outpatient Visit" + # Provider visiting Person, without a Care Site, within one day, delivering service + Home_Visit = "Home Visit" + # Patient engages with Provider through communication media + Telehealth_Visit = "Telehealth Visit" + # Person visiting pharmacy for dispensing of Drug, at a Care Site, within one day + Pharmacy_Visit = "Pharmacy Visit" + # Patient visiting dedicated institution, at a Care Site, within one day, for the purpose of a Measurement. + Laboratory_Visit = "Laboratory Visit" + # Person using transportation service for the purpose of initiating one of the other Visits, without a Care Site, within one day, potentially with Providers accompanying the Visit and delivering service + Ambulance_Visit = "Ambulance Visit" + # Person interacting with healthcare system, without a Care Site, within a day, with no Providers involved, for administrative purposes + Case_Management_Visit = "Case Management Visit" + + +class Entity(ConfiguredBaseModel): + """ + A physical, digital, conceptual, or other kind of thing with some common characteristics + """ + type: Literal["Entity"] = Field("Entity", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class NamedThing(Entity): + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["NamedThing"] = Field("NamedThing", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + +class Concept(NamedThing): + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Concept"] = Field("Concept", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + +class InformationEntity(NamedThing): + """ + An entity that describes some information + """ + describes: Optional[Any] = Field(None, description="""The thing that is being described""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["InformationEntity"] = Field("InformationEntity", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + +class PhysicalDevice(NamedThing): + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["PhysicalDevice"] = Field("PhysicalDevice", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + +class Intangible(Entity): + """ + An entity that is not a physical object, process, or information + """ + type: Literal["Intangible"] = Field("Intangible", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Role(Intangible): + type: Literal["Role"] = Field("Role", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Relationship(Intangible): + type: Literal["Relationship"] = Field("Relationship", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Location(ConfiguredBaseModel): + pass + + +class PointLocation(Location): + pass + + +class Observation(Entity): + """ + A statement about the state of something + """ + type: Literal["Observation"] = Field("Observation", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Specification(NamedThing): + """ + A specification of a thing + """ + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Specification"] = Field("Specification", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + +class Procedure(Specification): + """ + A canonical series of actions conducted in a certain order or manner + """ + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Procedure"] = Field("Procedure", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + +class MathematicalOperation(ConfiguredBaseModel): + """ + Application of a mathematical operation to one or more inputs to produce one or more outputs + """ + inputs: Optional[List[Any]] = Field(default_factory=list, description="""The inputs to the operation""") + outputs: Optional[List[Any]] = Field(default_factory=list, description="""The outputs of the operation""") + parts: Optional[List[MathematicalOperation]] = Field(default_factory=list, description="""The parts of the process""") + immediate_preceding_steps: Optional[List[MathematicalOperation]] = Field(default_factory=list, description="""The steps that immediately precede this step""") + + +class Collection(Intangible): + """ + A group of things. The collection may be heterogeneous or homogeneous. + """ + members: Optional[List[Union[Entity,NamedThing,Intangible,Observation,PostalAddress,Role,Relationship,Collection,Quantity,QuantityRange,TimePointOrTemporalInterval,Service,TemporalInterval,TimePoint,SimpleQuantity,Ratio,Duration,TemporalRelationship,HealthcareRole,HealthcareProvider,Patient,Concept,InformationEntity,PhysicalDevice,Specification,Place,Event,Agent,CreativeWork,Person,Organization,AutomatedAgent,HealthcareOrganization,LifeEvent,HealthcareEncounter,HealthcareConditionOccurrence,Landform,HealthcareSite,Procedure,QuantityKind,UnitConcept]]] = Field(default_factory=list, description="""The members of the collection""") + type: Literal["Collection"] = Field("Collection", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class QuantityKind(Concept): + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["QuantityKind"] = Field("QuantityKind", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + +class Quantity(Intangible): + has_quantity_kind: Optional[str] = Field(None, description="""The kind of quantity""") + type: Literal["Quantity"] = Field("Quantity", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class SimpleQuantity(Quantity): + """ + A quantity is a property that can be measured or counted + """ + value: Optional[float] = Field(None, description="""The value of the quantity""") + unit: Optional[str] = Field(None) + has_quantity_kind: Optional[str] = Field(None, description="""The kind of quantity""") + type: Literal["SimpleQuantity"] = Field("SimpleQuantity", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Ratio(Quantity): + """ + A tuple of two quantities + """ + numerator: Optional[Union[Quantity,SimpleQuantity,Ratio,Duration]] = Field(None, description="""The numerator of the ratio""") + denominator: Optional[Union[Quantity,SimpleQuantity,Ratio,Duration]] = Field(None, description="""The denominator of the ratio""") + has_quantity_kind: Optional[str] = Field(None, description="""The kind of quantity""") + type: Literal["Ratio"] = Field("Ratio", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class QuantityRange(Intangible): + """ + A quantity range is a property that can be measured or counted + """ + lower_bound: Optional[Union[Quantity,SimpleQuantity,Ratio,Duration]] = Field(None, description="""The lower bound of the range""") + upper_bound: Optional[Union[Quantity,SimpleQuantity,Ratio,Duration]] = Field(None, description="""The upper bound of the range""") + type: Literal["QuantityRange"] = Field("QuantityRange", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class UnitConversionOperation(MathematicalOperation): + """ + A unit conversion operation + """ + inputs: Optional[List[Union[Quantity,SimpleQuantity,Ratio,Duration]]] = Field(default_factory=list, description="""The input unit""") + outputs: Optional[List[Union[Quantity,SimpleQuantity,Ratio,Duration]]] = Field(default_factory=list, description="""The output unit""") + parts: Optional[List[MathematicalOperation]] = Field(default_factory=list, description="""The parts of the process""") + immediate_preceding_steps: Optional[List[MathematicalOperation]] = Field(default_factory=list, description="""The steps that immediately precede this step""") + + +class UnitConcept(Concept): + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["UnitConcept"] = Field("UnitConcept", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + +class Place(NamedThing): + """ + Entities that have a somewhat fixed, physical extension. + """ + address: Optional[PostalAddress] = Field(None) + geolocation: Optional[GeoPointLocation] = Field(None, description="""The geolocation of the place""") + bounding_coordinates: Optional[GeoBoxLocation] = Field(None, description="""The bounding coordinates of the place""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Place"] = Field("Place", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + +class Landform(Place): + """ + A natural feature of the solid surface of the Earth or other planetary body + """ + address: Optional[PostalAddress] = Field(None) + geolocation: Optional[GeoPointLocation] = Field(None, description="""The geolocation of the place""") + bounding_coordinates: Optional[GeoBoxLocation] = Field(None, description="""The bounding coordinates of the place""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Landform"] = Field("Landform", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + +class PostalAddress(Entity): + """ + Represents an Address + """ + street_address: Optional[str] = Field(None, description="""The street address""") + street_address_additional: Optional[str] = Field(None) + city: Optional[str] = Field(None, description="""The city""") + state: Optional[str] = Field(None, description="""The state""") + postal_code: Optional[str] = Field(None, description="""The postal code or zip code""") + country: Optional[str] = Field(None, description="""The country""") + type: Literal["PostalAddress"] = Field("PostalAddress", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class GeoPointLocation(PointLocation): + latitude: Optional[Decimal] = Field(None, description="""The latitude of the location""") + longitude: Optional[Decimal] = Field(None, description="""The longitude of the location""") + altitude: Optional[Decimal] = Field(None, description="""The altitude of the location""") + + +class GeoBoxLocation(Location): + west_bounding_coordinate: Optional[Decimal] = Field(None, description="""The westernmost coordinate of the location""") + east_bounding_coordinate: Optional[Decimal] = Field(None, description="""The easternmost coordinate of the location""") + north_bounding_coordinate: Optional[Decimal] = Field(None, description="""The northernmost coordinate of the location""") + south_bounding_coordinate: Optional[Decimal] = Field(None, description="""The southernmost coordinate of the location""") + + +class Event(NamedThing): + """ + A thing that happens + """ + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + happens_at: Optional[TimePoint] = Field(None) + has_interval: Optional[TemporalInterval] = Field(None) + has_duration: Optional[Duration] = Field(None) + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Event"] = Field("Event", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + +class TimePointOrTemporalInterval(Intangible): + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + type: Literal["TimePointOrTemporalInterval"] = Field("TimePointOrTemporalInterval", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class TemporalInterval(TimePointOrTemporalInterval): + """ + A period of time + """ + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + type: Literal["TemporalInterval"] = Field("TemporalInterval", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class TimePoint(TimePointOrTemporalInterval): + """ + A point in time. Can be fully specified, or specified in relative terms. + """ + year_value: Optional[int] = Field(None) + date_value: Optional[date] = Field(None) + time_value: Optional[str] = Field(None) + datetime_value: Optional[datetime ] = Field(None) + marker_event: Optional[str] = Field(None) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + type: Literal["TimePoint"] = Field("TimePoint", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Duration(Quantity): + """ + A length of time + """ + has_quantity_kind: Optional[str] = Field(None, description="""The kind of quantity""") + type: Literal["Duration"] = Field("Duration", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class TemporalRelationship(Relationship): + """ + A relationship to another time point + """ + predicate: Optional[RelativeTimeEnum] = Field(None, description="""The relationship between the two time points""") + relative_to: Optional[Union[TemporalInterval, TimePoint, str]] = Field(None) + type: Literal["TemporalRelationship"] = Field("TemporalRelationship", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Agent(NamedThing): + """ + Represents an Agent + """ + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Agent"] = Field("Agent", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + +class Person(Agent): + """ + Represents a Person + """ + primary_email: Optional[str] = Field(None, description="""The main email address of a person""") + birth_date: Optional[date] = Field(None, description="""Date on which a person is born""") + age_in_years: Optional[int] = Field(None, description="""Number of years since birth""") + vital_status: Optional[PersonStatus] = Field(None, description="""living or dead status""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Person"] = Field("Person", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + @validator('primary_email', allow_reuse=True) + def pattern_primary_email(cls, v): + pattern=re.compile(r"^\S+@[\S+\.]+\S+") + if isinstance(v,list): + for element in v: + if not pattern.match(element): + raise ValueError(f"Invalid primary_email format: {element}") + elif isinstance(v,str): + if not pattern.match(v): + raise ValueError(f"Invalid primary_email format: {v}") + return v + + +class Organization(Agent): + """ + Represents an Organization + """ + provides_services: Optional[List[Service]] = Field(default_factory=list) + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Organization"] = Field("Organization", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + +class AutomatedAgent(Agent): + """ + Represents an Automated Agent + """ + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["AutomatedAgent"] = Field("AutomatedAgent", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + +class LifeEvent(Event): + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + happens_at: Optional[TimePoint] = Field(None) + has_interval: Optional[TemporalInterval] = Field(None) + has_duration: Optional[Duration] = Field(None) + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["LifeEvent"] = Field("LifeEvent", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + +class CreativeWork(NamedThing): + """ + The most generic kind of creative work, including books, movies, photographs, software programs, etc. + """ + title: Optional[str] = Field(None, description="""The title of the item""") + abstract: Optional[str] = Field(None, description="""A summary of the item""") + rights: Optional[str] = Field(None, description="""Information about rights held in and over the item""") + creators: Optional[List[str]] = Field(default_factory=list, description="""The person or organization who created the work""") + contributors: Optional[List[str]] = Field(default_factory=list, description="""A person or organization that contributed to the creation of the work""") + contacts: Optional[List[str]] = Field(default_factory=list, description="""A contact point for a person or organization""") + keywords: Optional[List[str]] = Field(default_factory=list, description="""Keywords or tags used to describe this item""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["CreativeWork"] = Field("CreativeWork", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + +class Service(Intangible): + """ + A service provided by an organization + """ + type: Literal["Service"] = Field("Service", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class HealthcareSite(Place): + address: Optional[PostalAddress] = Field(None) + geolocation: Optional[GeoPointLocation] = Field(None, description="""The geolocation of the place""") + bounding_coordinates: Optional[GeoBoxLocation] = Field(None, description="""The bounding coordinates of the place""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["HealthcareSite"] = Field("HealthcareSite", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + +class HealthcareEncounter(Event): + """ + An interaction between a patient and one or more healthcare providers + """ + patient: Optional[Patient] = Field(None) + provider: Optional[HealthcareProvider] = Field(None) + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + happens_at: Optional[TimePoint] = Field(None) + has_interval: Optional[TemporalInterval] = Field(None) + has_duration: Optional[Duration] = Field(None) + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["HealthcareEncounter"] = Field("HealthcareEncounter", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[HealthcareEncounterClassification] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + +class HealthcareOrganization(Organization): + """ + An organization that provides healthcare services + """ + provides_services: Optional[List[Service]] = Field(default_factory=list) + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["HealthcareOrganization"] = Field("HealthcareOrganization", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + +class HealthcareRole(Role): + is_person: Optional[str] = Field(None) + type: Literal["HealthcareRole"] = Field("HealthcareRole", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class HealthcareProvider(HealthcareRole): + speciality: Optional[str] = Field(None) + care_site: Optional[str] = Field(None) + is_person: Optional[str] = Field(None) + type: Literal["HealthcareProvider"] = Field("HealthcareProvider", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class HealthcareConditionOccurrence(Event): + patient: Optional[Patient] = Field(None) + observed_during: Optional[str] = Field(None) + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + happens_at: Optional[TimePoint] = Field(None) + has_interval: Optional[TemporalInterval] = Field(None) + has_duration: Optional[Duration] = Field(None) + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["HealthcareConditionOccurrence"] = Field("HealthcareConditionOccurrence", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + + +class Patient(HealthcareRole): + is_person: Optional[str] = Field(None) + type: Literal["Patient"] = Field("Patient", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +# Update forward refs +# see https://pydantic-docs.helpmanual.io/usage/postponed_annotations/ +Entity.update_forward_refs() +NamedThing.update_forward_refs() +Concept.update_forward_refs() +InformationEntity.update_forward_refs() +PhysicalDevice.update_forward_refs() +Intangible.update_forward_refs() +Role.update_forward_refs() +Relationship.update_forward_refs() +Location.update_forward_refs() +PointLocation.update_forward_refs() +Observation.update_forward_refs() +Specification.update_forward_refs() +Procedure.update_forward_refs() +MathematicalOperation.update_forward_refs() +Collection.update_forward_refs() +QuantityKind.update_forward_refs() +Quantity.update_forward_refs() +SimpleQuantity.update_forward_refs() +Ratio.update_forward_refs() +QuantityRange.update_forward_refs() +UnitConversionOperation.update_forward_refs() +UnitConcept.update_forward_refs() +Place.update_forward_refs() +Landform.update_forward_refs() +PostalAddress.update_forward_refs() +GeoPointLocation.update_forward_refs() +GeoBoxLocation.update_forward_refs() +Event.update_forward_refs() +TimePointOrTemporalInterval.update_forward_refs() +TemporalInterval.update_forward_refs() +TimePoint.update_forward_refs() +Duration.update_forward_refs() +TemporalRelationship.update_forward_refs() +Agent.update_forward_refs() +Person.update_forward_refs() +Organization.update_forward_refs() +AutomatedAgent.update_forward_refs() +LifeEvent.update_forward_refs() +CreativeWork.update_forward_refs() +Service.update_forward_refs() +HealthcareSite.update_forward_refs() +HealthcareEncounter.update_forward_refs() +HealthcareOrganization.update_forward_refs() +HealthcareRole.update_forward_refs() +HealthcareProvider.update_forward_refs() +HealthcareConditionOccurrence.update_forward_refs() +Patient.update_forward_refs() + diff --git a/src/linkml_common/datamodel/investigations.py b/src/linkml_common/datamodel/investigations.py new file mode 100644 index 0000000..d8d9e42 --- /dev/null +++ b/src/linkml_common/datamodel/investigations.py @@ -0,0 +1,546 @@ +from __future__ import annotations +from datetime import ( + datetime, + date +) +from decimal import Decimal +from enum import Enum +import re +import sys +from typing import ( + Any, + List, + Literal, + Dict, + Optional, + Union +) +from pydantic.version import VERSION as PYDANTIC_VERSION +if int(PYDANTIC_VERSION[0])>=2: + from pydantic import ( + BaseModel, + ConfigDict, + Field, + field_validator + ) +else: + from pydantic import ( + BaseModel, + Field, + validator + ) + +metamodel_version = "None" +version = "None" + + +class WeakRefShimBaseModel(BaseModel): + __slots__ = '__weakref__' + +class ConfiguredBaseModel(WeakRefShimBaseModel, + validate_assignment = True, + validate_all = True, + underscore_attrs_are_private = True, + extra = "forbid", + arbitrary_types_allowed = True, + use_enum_values = True): + pass + + +class RelativeTimeEnum(str, Enum): + BEFORE = "BEFORE" + AFTER = "AFTER" + AT_SAME_TIME_AS = "AT_SAME_TIME_AS" + + +class CaseOrControlEnum(str, Enum): + case_role_in_case_control_study = "CASE" + control_role_in_case_control_study = "CONTROL" + + +class StudyDesignEnum(str): + pass + + +class InvestigativeProtocolEnum(str): + pass + + +class SampleProcessingEnum(str): + pass + + +class Identified(ConfiguredBaseModel): + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + + +class Typed(ConfiguredBaseModel): + type: Literal["Typed"] = Field("Typed", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Entity(Typed): + """ + A physical, digital, conceptual, or other kind of thing with some common characteristics + """ + type: Literal["Entity"] = Field("Entity", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Event(Entity, Identified): + """ + A thing that happens + """ + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + happens_at: Optional[TimePoint] = Field(None) + has_interval: Optional[TemporalInterval] = Field(None) + has_duration: Optional[Duration] = Field(None) + is_ongoing_as_of: Optional[TimePoint] = Field(None) + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Event"] = Field("Event", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Observation(Event): + """ + A statement about the state of something + """ + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + happens_at: Optional[TimePoint] = Field(None) + has_interval: Optional[TemporalInterval] = Field(None) + has_duration: Optional[Duration] = Field(None) + is_ongoing_as_of: Optional[TimePoint] = Field(None) + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Observation"] = Field("Observation", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Measurement(Observation): + quantity_measured: Optional[Union[Quantity,Duration,SimpleQuantity,Ratio]] = Field(None, description="""The quantity being measured""") + variable_measured: Optional[Variable] = Field(None, description="""The variable being measured""") + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + happens_at: Optional[TimePoint] = Field(None) + has_interval: Optional[TemporalInterval] = Field(None) + has_duration: Optional[Duration] = Field(None) + is_ongoing_as_of: Optional[TimePoint] = Field(None) + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Measurement"] = Field("Measurement", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Intangible(Entity): + """ + An entity that is not a physical object, process, or information + """ + type: Literal["Intangible"] = Field("Intangible", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Variable(Intangible): + allowed_units: Optional[List[str]] = Field(default_factory=list, description="""The units that are allowed for this variable""") + type: Literal["Variable"] = Field("Variable", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class TimePointOrTemporalInterval(Intangible): + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + type: Literal["TimePointOrTemporalInterval"] = Field("TimePointOrTemporalInterval", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class TemporalInterval(TimePointOrTemporalInterval): + """ + A period of time + """ + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + type: Literal["TemporalInterval"] = Field("TemporalInterval", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class TimePoint(TimePointOrTemporalInterval): + """ + A point in time. Can be fully specified, or specified in relative terms. + """ + year_value: Optional[int] = Field(None) + date_value: Optional[date] = Field(None) + time_value: Optional[str] = Field(None) + datetime_value: Optional[datetime ] = Field(None) + marker_event: Optional[str] = Field(None) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + type: Literal["TimePoint"] = Field("TimePoint", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Quantity(Intangible): + has_quantity_kind: Optional[str] = Field(None, description="""The kind of quantity""") + type: Literal["Quantity"] = Field("Quantity", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Duration(Quantity): + """ + A length of time + """ + has_quantity_kind: Optional[str] = Field(None, description="""The kind of quantity""") + type: Literal["Duration"] = Field("Duration", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class SimpleQuantity(Quantity): + """ + A quantity is a property that can be measured or counted + """ + value: Optional[float] = Field(None, description="""The value of the quantity""") + unit: Optional[str] = Field(None) + has_quantity_kind: Optional[str] = Field(None, description="""The kind of quantity""") + type: Literal["SimpleQuantity"] = Field("SimpleQuantity", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Ratio(Quantity): + """ + A tuple of two quantities + """ + numerator: Optional[Union[Quantity,Duration,SimpleQuantity,Ratio]] = Field(None, description="""The numerator of the ratio""") + denominator: Optional[Union[Quantity,Duration,SimpleQuantity,Ratio]] = Field(None, description="""The denominator of the ratio""") + has_quantity_kind: Optional[str] = Field(None, description="""The kind of quantity""") + type: Literal["Ratio"] = Field("Ratio", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class QuantityRange(Intangible): + """ + A quantity range is a property that can be measured or counted + """ + lower_bound: Optional[Union[Quantity,Duration,SimpleQuantity,Ratio]] = Field(None, description="""The lower bound of the range""") + upper_bound: Optional[Union[Quantity,Duration,SimpleQuantity,Ratio]] = Field(None, description="""The upper bound of the range""") + type: Literal["QuantityRange"] = Field("QuantityRange", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class NamedThing(Entity, Identified): + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["NamedThing"] = Field("NamedThing", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Concept(Intangible, Identified): + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Concept"] = Field("Concept", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class QuantityKind(Concept): + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["QuantityKind"] = Field("QuantityKind", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class UnitConcept(Concept): + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["UnitConcept"] = Field("UnitConcept", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class InformationEntity(Intangible, Identified): + """ + An entity that describes some information + """ + describes: Optional[Any] = Field(None, description="""The thing that is being described""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["InformationEntity"] = Field("InformationEntity", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class PhysicalDevice(NamedThing): + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["PhysicalDevice"] = Field("PhysicalDevice", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class StructuredValue(Intangible): + """ + A value that is a structured collection of other values + """ + type: Literal["StructuredValue"] = Field("StructuredValue", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Role(Intangible): + type: Literal["Role"] = Field("Role", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Relationship(Intangible): + type: Literal["Relationship"] = Field("Relationship", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class TemporalRelationship(Relationship): + """ + A relationship to another time point + """ + predicate: Optional[RelativeTimeEnum] = Field(None, description="""The relationship between the two time points""") + relative_to: Optional[Union[TemporalInterval, TimePoint, str]] = Field(None) + type: Literal["TemporalRelationship"] = Field("TemporalRelationship", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Location(StructuredValue): + type: Literal["Location"] = Field("Location", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class PointLocation(Location): + type: Literal["PointLocation"] = Field("PointLocation", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Specification(InformationEntity): + """ + A specification of a thing + """ + describes: Optional[Any] = Field(None, description="""The thing that is being described""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Specification"] = Field("Specification", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Procedure(Specification): + """ + A canonical series of actions conducted in a certain order or manner + """ + describes: Optional[Any] = Field(None, description="""The thing that is being described""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Procedure"] = Field("Procedure", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class EntitySet(Intangible): + """ + A group of things. The collection may be heterogeneous or homogeneous. + """ + members: Optional[List[Union[Entity,Event,Intangible,NamedThing,PhysicalDevice,SampleMaterial,Variable,TimePointOrTemporalInterval,Quantity,QuantityRange,Concept,InformationEntity,StructuredValue,Role,Relationship,EntitySet,TemporalRelationship,Location,PointLocation,Specification,Procedure,InvestigativeProtocol,StudyDesign,QuantityKind,UnitConcept,Duration,SimpleQuantity,Ratio,TemporalInterval,TimePoint,Observation,ExecutionOfProcedure,Investigation,PlannedProcess,MathematicalOperationExecution,MaterialCollection,MaterialProcessing,InvestigativeProcess,SampleCollectionProcess,DataGenerationFromSample,SampleProcessing,Measurement]]] = Field(default_factory=list, description="""The members of the collection""") + type: Literal["EntitySet"] = Field("EntitySet", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class ExecutionOfProcedure(Event): + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + happens_at: Optional[TimePoint] = Field(None) + has_interval: Optional[TemporalInterval] = Field(None) + has_duration: Optional[Duration] = Field(None) + is_ongoing_as_of: Optional[TimePoint] = Field(None) + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["ExecutionOfProcedure"] = Field("ExecutionOfProcedure", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class PlannedProcess(ExecutionOfProcedure): + """ + A process that follows a defined procedure or plan + """ + follows_procedure: Optional[str] = Field(None) + uses_physical_device: Optional[str] = Field(None) + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + happens_at: Optional[TimePoint] = Field(None) + has_interval: Optional[TemporalInterval] = Field(None) + has_duration: Optional[Duration] = Field(None) + is_ongoing_as_of: Optional[TimePoint] = Field(None) + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["PlannedProcess"] = Field("PlannedProcess", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class MathematicalOperationExecution(PlannedProcess): + """ + Application of a mathematical operation to one or more inputs to produce one or more outputs + """ + inputs: Optional[List[Any]] = Field(default_factory=list, description="""The inputs to the operation""") + outputs: Optional[List[Any]] = Field(default_factory=list, description="""The outputs of the operation""") + parts: Optional[List[str]] = Field(default_factory=list, description="""The parts of the process""") + immediate_preceding_steps: Optional[List[str]] = Field(default_factory=list, description="""The steps that immediately precede this step""") + follows_procedure: Optional[str] = Field(None) + uses_physical_device: Optional[str] = Field(None) + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + happens_at: Optional[TimePoint] = Field(None) + has_interval: Optional[TemporalInterval] = Field(None) + has_duration: Optional[Duration] = Field(None) + is_ongoing_as_of: Optional[TimePoint] = Field(None) + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["MathematicalOperationExecution"] = Field("MathematicalOperationExecution", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class MaterialCollection(PlannedProcess): + follows_procedure: Optional[str] = Field(None) + uses_physical_device: Optional[str] = Field(None) + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + happens_at: Optional[TimePoint] = Field(None) + has_interval: Optional[TemporalInterval] = Field(None) + has_duration: Optional[Duration] = Field(None) + is_ongoing_as_of: Optional[TimePoint] = Field(None) + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["MaterialCollection"] = Field("MaterialCollection", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class MaterialProcessing(PlannedProcess): + follows_procedure: Optional[str] = Field(None) + uses_physical_device: Optional[str] = Field(None) + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + happens_at: Optional[TimePoint] = Field(None) + has_interval: Optional[TemporalInterval] = Field(None) + has_duration: Optional[Duration] = Field(None) + is_ongoing_as_of: Optional[TimePoint] = Field(None) + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["MaterialProcessing"] = Field("MaterialProcessing", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Investigation(Event): + objectives: Optional[str] = Field(None) + variables: Optional[List[Variable]] = Field(default_factory=list) + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + happens_at: Optional[TimePoint] = Field(None) + has_interval: Optional[TemporalInterval] = Field(None) + has_duration: Optional[Duration] = Field(None) + is_ongoing_as_of: Optional[TimePoint] = Field(None) + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Investigation"] = Field("Investigation", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class InvestigativeProtocol(Procedure): + protocols_io_url: Optional[str] = Field(None) + describes: Optional[Any] = Field(None, description="""The thing that is being described""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["InvestigativeProtocol"] = Field("InvestigativeProtocol", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class StudyDesign(Procedure): + describes: Optional[Any] = Field(None, description="""The thing that is being described""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["StudyDesign"] = Field("StudyDesign", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class SampleMaterial(NamedThing): + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["SampleMaterial"] = Field("SampleMaterial", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class InvestigativeProcess(PlannedProcess): + follows_procedure: Optional[str] = Field(None) + part_of: Optional[str] = Field(None) + uses_physical_device: Optional[str] = Field(None) + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + happens_at: Optional[TimePoint] = Field(None) + has_interval: Optional[TemporalInterval] = Field(None) + has_duration: Optional[Duration] = Field(None) + is_ongoing_as_of: Optional[TimePoint] = Field(None) + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["InvestigativeProcess"] = Field("InvestigativeProcess", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class SampleCollectionProcess(InvestigativeProcess): + material_collected: Optional[str] = Field(None) + collected_from: Optional[str] = Field(None) + follows_procedure: Optional[str] = Field(None) + part_of: Optional[str] = Field(None) + uses_physical_device: Optional[str] = Field(None) + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + happens_at: Optional[TimePoint] = Field(None) + has_interval: Optional[TemporalInterval] = Field(None) + has_duration: Optional[Duration] = Field(None) + is_ongoing_as_of: Optional[TimePoint] = Field(None) + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["SampleCollectionProcess"] = Field("SampleCollectionProcess", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class SampleProcessing(MaterialProcessing): + follows_procedure: Optional[str] = Field(None) + uses_physical_device: Optional[str] = Field(None) + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + happens_at: Optional[TimePoint] = Field(None) + has_interval: Optional[TemporalInterval] = Field(None) + has_duration: Optional[Duration] = Field(None) + is_ongoing_as_of: Optional[TimePoint] = Field(None) + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["SampleProcessing"] = Field("SampleProcessing", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class DataGenerationFromSample(InvestigativeProcess): + follows_procedure: Optional[str] = Field(None) + part_of: Optional[str] = Field(None) + uses_physical_device: Optional[str] = Field(None) + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + happens_at: Optional[TimePoint] = Field(None) + has_interval: Optional[TemporalInterval] = Field(None) + has_duration: Optional[Duration] = Field(None) + is_ongoing_as_of: Optional[TimePoint] = Field(None) + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["DataGenerationFromSample"] = Field("DataGenerationFromSample", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +# Update forward refs +# see https://pydantic-docs.helpmanual.io/usage/postponed_annotations/ +Identified.update_forward_refs() +Typed.update_forward_refs() +Entity.update_forward_refs() +Event.update_forward_refs() +Observation.update_forward_refs() +Measurement.update_forward_refs() +Intangible.update_forward_refs() +Variable.update_forward_refs() +TimePointOrTemporalInterval.update_forward_refs() +TemporalInterval.update_forward_refs() +TimePoint.update_forward_refs() +Quantity.update_forward_refs() +Duration.update_forward_refs() +SimpleQuantity.update_forward_refs() +Ratio.update_forward_refs() +QuantityRange.update_forward_refs() +NamedThing.update_forward_refs() +Concept.update_forward_refs() +QuantityKind.update_forward_refs() +UnitConcept.update_forward_refs() +InformationEntity.update_forward_refs() +PhysicalDevice.update_forward_refs() +StructuredValue.update_forward_refs() +Role.update_forward_refs() +Relationship.update_forward_refs() +TemporalRelationship.update_forward_refs() +Location.update_forward_refs() +PointLocation.update_forward_refs() +Specification.update_forward_refs() +Procedure.update_forward_refs() +EntitySet.update_forward_refs() +ExecutionOfProcedure.update_forward_refs() +PlannedProcess.update_forward_refs() +MathematicalOperationExecution.update_forward_refs() +MaterialCollection.update_forward_refs() +MaterialProcessing.update_forward_refs() +Investigation.update_forward_refs() +InvestigativeProtocol.update_forward_refs() +StudyDesign.update_forward_refs() +SampleMaterial.update_forward_refs() +InvestigativeProcess.update_forward_refs() +SampleCollectionProcess.update_forward_refs() +SampleProcessing.update_forward_refs() +DataGenerationFromSample.update_forward_refs() + diff --git a/src/linkml_common/datamodel/measurements.py b/src/linkml_common/datamodel/measurements.py new file mode 100644 index 0000000..c43c9b7 --- /dev/null +++ b/src/linkml_common/datamodel/measurements.py @@ -0,0 +1,339 @@ +from __future__ import annotations +from datetime import ( + datetime, + date +) +from decimal import Decimal +from enum import Enum +import re +import sys +from typing import ( + Any, + List, + Literal, + Dict, + Optional, + Union +) +from pydantic.version import VERSION as PYDANTIC_VERSION +if int(PYDANTIC_VERSION[0])>=2: + from pydantic import ( + BaseModel, + ConfigDict, + Field, + field_validator + ) +else: + from pydantic import ( + BaseModel, + Field, + validator + ) + +metamodel_version = "None" +version = "None" + + +class WeakRefShimBaseModel(BaseModel): + __slots__ = '__weakref__' + +class ConfiguredBaseModel(WeakRefShimBaseModel, + validate_assignment = True, + validate_all = True, + underscore_attrs_are_private = True, + extra = "forbid", + arbitrary_types_allowed = True, + use_enum_values = True): + pass + + +class RelativeTimeEnum(str, Enum): + BEFORE = "BEFORE" + AFTER = "AFTER" + AT_SAME_TIME_AS = "AT_SAME_TIME_AS" + + +class Identified(ConfiguredBaseModel): + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + + +class Typed(ConfiguredBaseModel): + type: Literal["Typed"] = Field("Typed", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Entity(Typed): + """ + A physical, digital, conceptual, or other kind of thing with some common characteristics + """ + type: Literal["Entity"] = Field("Entity", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Intangible(Entity): + """ + An entity that is not a physical object, process, or information + """ + type: Literal["Intangible"] = Field("Intangible", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class NamedThing(Entity, Identified): + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["NamedThing"] = Field("NamedThing", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Concept(Intangible, Identified): + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Concept"] = Field("Concept", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class InformationEntity(Intangible, Identified): + """ + An entity that describes some information + """ + describes: Optional[Any] = Field(None, description="""The thing that is being described""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["InformationEntity"] = Field("InformationEntity", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class PhysicalDevice(NamedThing): + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["PhysicalDevice"] = Field("PhysicalDevice", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class StructuredValue(Intangible): + """ + A value that is a structured collection of other values + """ + type: Literal["StructuredValue"] = Field("StructuredValue", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Role(Intangible): + type: Literal["Role"] = Field("Role", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Relationship(Intangible): + type: Literal["Relationship"] = Field("Relationship", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Location(StructuredValue): + type: Literal["Location"] = Field("Location", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class PointLocation(Location): + type: Literal["PointLocation"] = Field("PointLocation", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Specification(InformationEntity): + """ + A specification of a thing + """ + describes: Optional[Any] = Field(None, description="""The thing that is being described""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Specification"] = Field("Specification", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Procedure(Specification): + """ + A canonical series of actions conducted in a certain order or manner + """ + describes: Optional[Any] = Field(None, description="""The thing that is being described""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Procedure"] = Field("Procedure", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class EntitySet(Intangible): + """ + A group of things. The collection may be heterogeneous or homogeneous. + """ + members: Optional[List[Union[Entity,Intangible,NamedThing,Event,Observation,Measurement,PhysicalDevice,Concept,InformationEntity,StructuredValue,Role,Relationship,EntitySet,Quantity,QuantityRange,TimePointOrTemporalInterval,Variable,TemporalInterval,TimePoint,SimpleQuantity,Ratio,Duration,TemporalRelationship,Location,PointLocation,Specification,Procedure,QuantityKind,UnitConcept]]] = Field(default_factory=list, description="""The members of the collection""") + type: Literal["EntitySet"] = Field("EntitySet", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class QuantityKind(Concept): + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["QuantityKind"] = Field("QuantityKind", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Quantity(Intangible): + has_quantity_kind: Optional[str] = Field(None, description="""The kind of quantity""") + type: Literal["Quantity"] = Field("Quantity", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class SimpleQuantity(Quantity): + """ + A quantity is a property that can be measured or counted + """ + value: Optional[float] = Field(None, description="""The value of the quantity""") + unit: Optional[str] = Field(None) + has_quantity_kind: Optional[str] = Field(None, description="""The kind of quantity""") + type: Literal["SimpleQuantity"] = Field("SimpleQuantity", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Ratio(Quantity): + """ + A tuple of two quantities + """ + numerator: Optional[Union[Quantity,SimpleQuantity,Ratio,Duration]] = Field(None, description="""The numerator of the ratio""") + denominator: Optional[Union[Quantity,SimpleQuantity,Ratio,Duration]] = Field(None, description="""The denominator of the ratio""") + has_quantity_kind: Optional[str] = Field(None, description="""The kind of quantity""") + type: Literal["Ratio"] = Field("Ratio", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class QuantityRange(Intangible): + """ + A quantity range is a property that can be measured or counted + """ + lower_bound: Optional[Union[Quantity,SimpleQuantity,Ratio,Duration]] = Field(None, description="""The lower bound of the range""") + upper_bound: Optional[Union[Quantity,SimpleQuantity,Ratio,Duration]] = Field(None, description="""The upper bound of the range""") + type: Literal["QuantityRange"] = Field("QuantityRange", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class UnitConcept(Concept): + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["UnitConcept"] = Field("UnitConcept", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Event(Entity, Identified): + """ + A thing that happens + """ + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + happens_at: Optional[TimePoint] = Field(None) + has_interval: Optional[TemporalInterval] = Field(None) + has_duration: Optional[Duration] = Field(None) + is_ongoing_as_of: Optional[TimePoint] = Field(None) + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Event"] = Field("Event", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Observation(Event): + """ + A statement about the state of something + """ + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + happens_at: Optional[TimePoint] = Field(None) + has_interval: Optional[TemporalInterval] = Field(None) + has_duration: Optional[Duration] = Field(None) + is_ongoing_as_of: Optional[TimePoint] = Field(None) + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Observation"] = Field("Observation", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class TimePointOrTemporalInterval(Intangible): + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + type: Literal["TimePointOrTemporalInterval"] = Field("TimePointOrTemporalInterval", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class TemporalInterval(TimePointOrTemporalInterval): + """ + A period of time + """ + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + type: Literal["TemporalInterval"] = Field("TemporalInterval", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class TimePoint(TimePointOrTemporalInterval): + """ + A point in time. Can be fully specified, or specified in relative terms. + """ + year_value: Optional[int] = Field(None) + date_value: Optional[date] = Field(None) + time_value: Optional[str] = Field(None) + datetime_value: Optional[datetime ] = Field(None) + marker_event: Optional[str] = Field(None) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + type: Literal["TimePoint"] = Field("TimePoint", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Duration(Quantity): + """ + A length of time + """ + has_quantity_kind: Optional[str] = Field(None, description="""The kind of quantity""") + type: Literal["Duration"] = Field("Duration", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class TemporalRelationship(Relationship): + """ + A relationship to another time point + """ + predicate: Optional[RelativeTimeEnum] = Field(None, description="""The relationship between the two time points""") + relative_to: Optional[Union[TemporalInterval, TimePoint, str]] = Field(None) + type: Literal["TemporalRelationship"] = Field("TemporalRelationship", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Measurement(Observation): + quantity_measured: Optional[Union[Quantity,SimpleQuantity,Ratio,Duration]] = Field(None, description="""The quantity being measured""") + variable_measured: Optional[Variable] = Field(None, description="""The variable being measured""") + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + happens_at: Optional[TimePoint] = Field(None) + has_interval: Optional[TemporalInterval] = Field(None) + has_duration: Optional[Duration] = Field(None) + is_ongoing_as_of: Optional[TimePoint] = Field(None) + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Measurement"] = Field("Measurement", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Variable(Intangible): + allowed_units: Optional[List[str]] = Field(default_factory=list, description="""The units that are allowed for this variable""") + type: Literal["Variable"] = Field("Variable", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +# Update forward refs +# see https://pydantic-docs.helpmanual.io/usage/postponed_annotations/ +Identified.update_forward_refs() +Typed.update_forward_refs() +Entity.update_forward_refs() +Intangible.update_forward_refs() +NamedThing.update_forward_refs() +Concept.update_forward_refs() +InformationEntity.update_forward_refs() +PhysicalDevice.update_forward_refs() +StructuredValue.update_forward_refs() +Role.update_forward_refs() +Relationship.update_forward_refs() +Location.update_forward_refs() +PointLocation.update_forward_refs() +Specification.update_forward_refs() +Procedure.update_forward_refs() +EntitySet.update_forward_refs() +QuantityKind.update_forward_refs() +Quantity.update_forward_refs() +SimpleQuantity.update_forward_refs() +Ratio.update_forward_refs() +QuantityRange.update_forward_refs() +UnitConcept.update_forward_refs() +Event.update_forward_refs() +Observation.update_forward_refs() +TimePointOrTemporalInterval.update_forward_refs() +TemporalInterval.update_forward_refs() +TimePoint.update_forward_refs() +Duration.update_forward_refs() +TemporalRelationship.update_forward_refs() +Measurement.update_forward_refs() +Variable.update_forward_refs() + diff --git a/src/linkml_common/datamodel/patterns.py b/src/linkml_common/datamodel/patterns.py new file mode 100644 index 0000000..52440a0 --- /dev/null +++ b/src/linkml_common/datamodel/patterns.py @@ -0,0 +1,216 @@ +from __future__ import annotations +from datetime import ( + datetime, + date +) +from decimal import Decimal +from enum import Enum +import re +import sys +from typing import ( + Any, + List, + Literal, + Dict, + Optional, + Union +) +from pydantic.version import VERSION as PYDANTIC_VERSION +if int(PYDANTIC_VERSION[0])>=2: + from pydantic import ( + BaseModel, + ConfigDict, + Field, + field_validator + ) +else: + from pydantic import ( + BaseModel, + Field, + validator + ) + +metamodel_version = "None" +version = "None" + + +class WeakRefShimBaseModel(BaseModel): + __slots__ = '__weakref__' + +class ConfiguredBaseModel(WeakRefShimBaseModel, + validate_assignment = True, + validate_all = True, + underscore_attrs_are_private = True, + extra = "forbid", + arbitrary_types_allowed = True, + use_enum_values = True): + pass + + +class ModelingAbstraction(ConfiguredBaseModel): + pass + + +class GraphElementMixin(ModelingAbstraction): + pass + + +class GraphMixin(GraphElementMixin): + pass + + +class GraphNodeMixin(GraphElementMixin): + pass + + +class GraphEdgeMixin(GraphElementMixin): + pass + + +class TreeElementMixin(ModelingAbstraction): + pass + + +class TreeMixin(TreeElementMixin): + pass + + +class SubTreeMixin(TreeMixin): + pass + + +class TreeNodeMixin(TreeElementMixin): + pass + + +class DiscreteEntity(ModelingAbstraction): + pass + + +class Composite(TreeMixin, ModelingAbstraction): + """ + A thing that can be composed of other things + """ + components: Optional[List[Union[AtomicDiscreteEntity, Composite]]] = Field(default_factory=list) + + +class SimpleComposite(Composite, SubTreeMixin): + """ + A thing that can be composed of only AtomicDiscreteEntities + """ + components: Optional[List[AtomicDiscreteEntity]] = Field(default_factory=list) + + +class AtomicDiscreteEntity(DiscreteEntity, TreeNodeMixin): + """ + A thing that cannot be decomposed into smaller parts, within a given system of components + """ + pass + + +class System(Composite, GraphMixin): + """ + A system is a composite entity that has connected components + """ + connections: Optional[List[SystemConnection]] = Field(default_factory=list) + components: Optional[List[Union[AtomicSystemComponent, SubSystem]]] = Field(default_factory=list) + + +class SubSystem(System): + """ + A system that is part of a larger system + """ + connections: Optional[List[SystemConnection]] = Field(default_factory=list) + components: Optional[List[Union[AtomicSystemComponent, SubSystem]]] = Field(default_factory=list) + + +class AtomicSystemComponent(AtomicDiscreteEntity): + """ + A system component that cannot be decomposed into smaller parts + """ + pass + + +class Relationship(GraphEdgeMixin, ModelingAbstraction): + """ + A relationship between two or more entities + """ + pass + + +class BinaryRelationship(Relationship): + pass + + +class MultiNAryRelationship(Relationship): + pass + + +class BinaryDirectedRelationship(BinaryRelationship): + subject: Optional[DiscreteEntity] = Field(None, description="""The subject of a relationship""") + object: Optional[DiscreteEntity] = Field(None, description="""The object of a relationship""") + + +class SystemConnection(BinaryDirectedRelationship): + """ + A connection between two system components + """ + subject: Optional[Union[AtomicSystemComponent, SubSystem]] = Field(None, description="""The subject of a relationship""") + object: Optional[Union[AtomicSystemComponent, SubSystem]] = Field(None, description="""The object of a relationship""") + + +class StateTransitionNetworkElement(ModelingAbstraction): + """ + An element in a state transition network + """ + pass + + +class StateTransitionNetwork(StateTransitionNetworkElement, GraphMixin): + """ + A network of state transitions + """ + pass + + +class StateTransition(StateTransitionNetworkElement): + before: Optional[State] = Field(None, description="""The previous state""") + after: Optional[State] = Field(None, description="""The next state""") + conditions: Optional[Any] = Field(None, description="""Conditions under which the transition occurs""") + + +class State(StateTransitionNetworkElement): + """ + A state in a state transition network + """ + pass + + +# Update forward refs +# see https://pydantic-docs.helpmanual.io/usage/postponed_annotations/ +ModelingAbstraction.update_forward_refs() +GraphElementMixin.update_forward_refs() +GraphMixin.update_forward_refs() +GraphNodeMixin.update_forward_refs() +GraphEdgeMixin.update_forward_refs() +TreeElementMixin.update_forward_refs() +TreeMixin.update_forward_refs() +SubTreeMixin.update_forward_refs() +TreeNodeMixin.update_forward_refs() +DiscreteEntity.update_forward_refs() +Composite.update_forward_refs() +SimpleComposite.update_forward_refs() +AtomicDiscreteEntity.update_forward_refs() +System.update_forward_refs() +SubSystem.update_forward_refs() +AtomicSystemComponent.update_forward_refs() +Relationship.update_forward_refs() +BinaryRelationship.update_forward_refs() +MultiNAryRelationship.update_forward_refs() +BinaryDirectedRelationship.update_forward_refs() +SystemConnection.update_forward_refs() +StateTransitionNetworkElement.update_forward_refs() +StateTransitionNetwork.update_forward_refs() +StateTransition.update_forward_refs() +State.update_forward_refs() + diff --git a/src/linkml_common/datamodel/plannedprocess.py b/src/linkml_common/datamodel/plannedprocess.py new file mode 100644 index 0000000..23e4736 --- /dev/null +++ b/src/linkml_common/datamodel/plannedprocess.py @@ -0,0 +1,431 @@ +from __future__ import annotations +from datetime import ( + datetime, + date +) +from decimal import Decimal +from enum import Enum +import re +import sys +from typing import ( + Any, + List, + Literal, + Dict, + Optional, + Union +) +from pydantic.version import VERSION as PYDANTIC_VERSION +if int(PYDANTIC_VERSION[0])>=2: + from pydantic import ( + BaseModel, + ConfigDict, + Field, + field_validator + ) +else: + from pydantic import ( + BaseModel, + Field, + validator + ) + +metamodel_version = "None" +version = "None" + + +class WeakRefShimBaseModel(BaseModel): + __slots__ = '__weakref__' + +class ConfiguredBaseModel(WeakRefShimBaseModel, + validate_assignment = True, + validate_all = True, + underscore_attrs_are_private = True, + extra = "forbid", + arbitrary_types_allowed = True, + use_enum_values = True): + pass + + +class RelativeTimeEnum(str, Enum): + BEFORE = "BEFORE" + AFTER = "AFTER" + AT_SAME_TIME_AS = "AT_SAME_TIME_AS" + + +class Identified(ConfiguredBaseModel): + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + + +class Typed(ConfiguredBaseModel): + type: Literal["Typed"] = Field("Typed", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Entity(Typed): + """ + A physical, digital, conceptual, or other kind of thing with some common characteristics + """ + type: Literal["Entity"] = Field("Entity", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Intangible(Entity): + """ + An entity that is not a physical object, process, or information + """ + type: Literal["Intangible"] = Field("Intangible", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Quantity(Intangible): + has_quantity_kind: Optional[str] = Field(None, description="""The kind of quantity""") + type: Literal["Quantity"] = Field("Quantity", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class SimpleQuantity(Quantity): + """ + A quantity is a property that can be measured or counted + """ + value: Optional[float] = Field(None, description="""The value of the quantity""") + unit: Optional[str] = Field(None) + has_quantity_kind: Optional[str] = Field(None, description="""The kind of quantity""") + type: Literal["SimpleQuantity"] = Field("SimpleQuantity", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Ratio(Quantity): + """ + A tuple of two quantities + """ + numerator: Optional[Union[Quantity,SimpleQuantity,Ratio,Duration]] = Field(None, description="""The numerator of the ratio""") + denominator: Optional[Union[Quantity,SimpleQuantity,Ratio,Duration]] = Field(None, description="""The denominator of the ratio""") + has_quantity_kind: Optional[str] = Field(None, description="""The kind of quantity""") + type: Literal["Ratio"] = Field("Ratio", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class QuantityRange(Intangible): + """ + A quantity range is a property that can be measured or counted + """ + lower_bound: Optional[Union[Quantity,SimpleQuantity,Ratio,Duration]] = Field(None, description="""The lower bound of the range""") + upper_bound: Optional[Union[Quantity,SimpleQuantity,Ratio,Duration]] = Field(None, description="""The upper bound of the range""") + type: Literal["QuantityRange"] = Field("QuantityRange", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Variable(Intangible): + allowed_units: Optional[List[str]] = Field(default_factory=list, description="""The units that are allowed for this variable""") + type: Literal["Variable"] = Field("Variable", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class NamedThing(Entity, Identified): + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["NamedThing"] = Field("NamedThing", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Concept(Intangible, Identified): + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Concept"] = Field("Concept", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class QuantityKind(Concept): + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["QuantityKind"] = Field("QuantityKind", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class UnitConcept(Concept): + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["UnitConcept"] = Field("UnitConcept", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class InformationEntity(Intangible, Identified): + """ + An entity that describes some information + """ + describes: Optional[Any] = Field(None, description="""The thing that is being described""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["InformationEntity"] = Field("InformationEntity", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class PhysicalDevice(NamedThing): + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["PhysicalDevice"] = Field("PhysicalDevice", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class StructuredValue(Intangible): + """ + A value that is a structured collection of other values + """ + type: Literal["StructuredValue"] = Field("StructuredValue", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Role(Intangible): + type: Literal["Role"] = Field("Role", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Relationship(Intangible): + type: Literal["Relationship"] = Field("Relationship", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Location(StructuredValue): + type: Literal["Location"] = Field("Location", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class PointLocation(Location): + type: Literal["PointLocation"] = Field("PointLocation", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Specification(InformationEntity): + """ + A specification of a thing + """ + describes: Optional[Any] = Field(None, description="""The thing that is being described""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Specification"] = Field("Specification", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Procedure(Specification): + """ + A canonical series of actions conducted in a certain order or manner + """ + describes: Optional[Any] = Field(None, description="""The thing that is being described""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Procedure"] = Field("Procedure", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class EntitySet(Intangible): + """ + A group of things. The collection may be heterogeneous or homogeneous. + """ + members: Optional[List[Union[Entity,Intangible,NamedThing,Event,Observation,ExecutionOfProcedure,PlannedProcess,ComputationalPlannedProcess,MaterialCollection,MaterialProcessing,Measurement,PhysicalDevice,Quantity,QuantityRange,Variable,Concept,InformationEntity,StructuredValue,Role,Relationship,EntitySet,TimePointOrTemporalInterval,PlannedProcessConfiguration,TemporalInterval,TimePoint,TemporalRelationship,Location,PointLocation,Specification,Procedure,QuantityKind,UnitConcept,SimpleQuantity,Ratio,Duration]]] = Field(default_factory=list, description="""The members of the collection""") + type: Literal["EntitySet"] = Field("EntitySet", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Event(Entity, Identified): + """ + A thing that happens + """ + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + happens_at: Optional[TimePoint] = Field(None) + has_interval: Optional[TemporalInterval] = Field(None) + has_duration: Optional[Duration] = Field(None) + is_ongoing_as_of: Optional[TimePoint] = Field(None) + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Event"] = Field("Event", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Observation(Event): + """ + A statement about the state of something + """ + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + happens_at: Optional[TimePoint] = Field(None) + has_interval: Optional[TemporalInterval] = Field(None) + has_duration: Optional[Duration] = Field(None) + is_ongoing_as_of: Optional[TimePoint] = Field(None) + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Observation"] = Field("Observation", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Measurement(Observation): + quantity_measured: Optional[Union[Quantity,SimpleQuantity,Ratio,Duration]] = Field(None, description="""The quantity being measured""") + variable_measured: Optional[Variable] = Field(None, description="""The variable being measured""") + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + happens_at: Optional[TimePoint] = Field(None) + has_interval: Optional[TemporalInterval] = Field(None) + has_duration: Optional[Duration] = Field(None) + is_ongoing_as_of: Optional[TimePoint] = Field(None) + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Measurement"] = Field("Measurement", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class TimePointOrTemporalInterval(Intangible): + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + type: Literal["TimePointOrTemporalInterval"] = Field("TimePointOrTemporalInterval", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class TemporalInterval(TimePointOrTemporalInterval): + """ + A period of time + """ + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + type: Literal["TemporalInterval"] = Field("TemporalInterval", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class TimePoint(TimePointOrTemporalInterval): + """ + A point in time. Can be fully specified, or specified in relative terms. + """ + year_value: Optional[int] = Field(None) + date_value: Optional[date] = Field(None) + time_value: Optional[str] = Field(None) + datetime_value: Optional[datetime ] = Field(None) + marker_event: Optional[str] = Field(None) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + type: Literal["TimePoint"] = Field("TimePoint", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Duration(Quantity): + """ + A length of time + """ + has_quantity_kind: Optional[str] = Field(None, description="""The kind of quantity""") + type: Literal["Duration"] = Field("Duration", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class TemporalRelationship(Relationship): + """ + A relationship to another time point + """ + predicate: Optional[RelativeTimeEnum] = Field(None, description="""The relationship between the two time points""") + relative_to: Optional[Union[TemporalInterval, TimePoint, str]] = Field(None) + type: Literal["TemporalRelationship"] = Field("TemporalRelationship", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class ExecutionOfProcedure(Event): + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + happens_at: Optional[TimePoint] = Field(None) + has_interval: Optional[TemporalInterval] = Field(None) + has_duration: Optional[Duration] = Field(None) + is_ongoing_as_of: Optional[TimePoint] = Field(None) + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["ExecutionOfProcedure"] = Field("ExecutionOfProcedure", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class PlannedProcessConfiguration(Intangible): + type: Literal["PlannedProcessConfiguration"] = Field("PlannedProcessConfiguration", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class PlannedProcess(ExecutionOfProcedure): + """ + A process that follows a defined procedure or plan + """ + follows_procedure: Optional[str] = Field(None) + uses_physical_device: Optional[str] = Field(None) + uses_configuration: Optional[PlannedProcessConfiguration] = Field(None) + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + happens_at: Optional[TimePoint] = Field(None) + has_interval: Optional[TemporalInterval] = Field(None) + has_duration: Optional[Duration] = Field(None) + is_ongoing_as_of: Optional[TimePoint] = Field(None) + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["PlannedProcess"] = Field("PlannedProcess", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class ComputationalPlannedProcess(PlannedProcess): + """ + Application of a mathematical operation to one or more inputs to produce one or more outputs + """ + inputs: Optional[List[Any]] = Field(default_factory=list, description="""The inputs to the operation""") + outputs: Optional[List[Any]] = Field(default_factory=list, description="""The outputs of the operation""") + parts: Optional[List[str]] = Field(default_factory=list, description="""The parts of the process""") + immediate_preceding_steps: Optional[List[str]] = Field(default_factory=list, description="""The steps that immediately precede this step""") + follows_procedure: Optional[str] = Field(None) + uses_physical_device: Optional[str] = Field(None) + uses_configuration: Optional[PlannedProcessConfiguration] = Field(None) + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + happens_at: Optional[TimePoint] = Field(None) + has_interval: Optional[TemporalInterval] = Field(None) + has_duration: Optional[Duration] = Field(None) + is_ongoing_as_of: Optional[TimePoint] = Field(None) + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["ComputationalPlannedProcess"] = Field("ComputationalPlannedProcess", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class MaterialCollection(PlannedProcess): + follows_procedure: Optional[str] = Field(None) + uses_physical_device: Optional[str] = Field(None) + uses_configuration: Optional[PlannedProcessConfiguration] = Field(None) + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + happens_at: Optional[TimePoint] = Field(None) + has_interval: Optional[TemporalInterval] = Field(None) + has_duration: Optional[Duration] = Field(None) + is_ongoing_as_of: Optional[TimePoint] = Field(None) + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["MaterialCollection"] = Field("MaterialCollection", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class MaterialProcessing(PlannedProcess): + follows_procedure: Optional[str] = Field(None) + uses_physical_device: Optional[str] = Field(None) + uses_configuration: Optional[PlannedProcessConfiguration] = Field(None) + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + happens_at: Optional[TimePoint] = Field(None) + has_interval: Optional[TemporalInterval] = Field(None) + has_duration: Optional[Duration] = Field(None) + is_ongoing_as_of: Optional[TimePoint] = Field(None) + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["MaterialProcessing"] = Field("MaterialProcessing", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +# Update forward refs +# see https://pydantic-docs.helpmanual.io/usage/postponed_annotations/ +Identified.update_forward_refs() +Typed.update_forward_refs() +Entity.update_forward_refs() +Intangible.update_forward_refs() +Quantity.update_forward_refs() +SimpleQuantity.update_forward_refs() +Ratio.update_forward_refs() +QuantityRange.update_forward_refs() +Variable.update_forward_refs() +NamedThing.update_forward_refs() +Concept.update_forward_refs() +QuantityKind.update_forward_refs() +UnitConcept.update_forward_refs() +InformationEntity.update_forward_refs() +PhysicalDevice.update_forward_refs() +StructuredValue.update_forward_refs() +Role.update_forward_refs() +Relationship.update_forward_refs() +Location.update_forward_refs() +PointLocation.update_forward_refs() +Specification.update_forward_refs() +Procedure.update_forward_refs() +EntitySet.update_forward_refs() +Event.update_forward_refs() +Observation.update_forward_refs() +Measurement.update_forward_refs() +TimePointOrTemporalInterval.update_forward_refs() +TemporalInterval.update_forward_refs() +TimePoint.update_forward_refs() +Duration.update_forward_refs() +TemporalRelationship.update_forward_refs() +ExecutionOfProcedure.update_forward_refs() +PlannedProcessConfiguration.update_forward_refs() +PlannedProcess.update_forward_refs() +ComputationalPlannedProcess.update_forward_refs() +MaterialCollection.update_forward_refs() +MaterialProcessing.update_forward_refs() + diff --git a/src/linkml_common/datamodel/quantities.py b/src/linkml_common/datamodel/quantities.py new file mode 100644 index 0000000..ce395ce --- /dev/null +++ b/src/linkml_common/datamodel/quantities.py @@ -0,0 +1,318 @@ +from __future__ import annotations +from datetime import ( + datetime, + date +) +from decimal import Decimal +from enum import Enum +import re +import sys +from typing import ( + Any, + List, + Literal, + Dict, + Optional, + Union +) +from pydantic.version import VERSION as PYDANTIC_VERSION +if int(PYDANTIC_VERSION[0])>=2: + from pydantic import ( + BaseModel, + ConfigDict, + Field, + field_validator + ) +else: + from pydantic import ( + BaseModel, + Field, + validator + ) + +metamodel_version = "None" +version = "None" + + +class WeakRefShimBaseModel(BaseModel): + __slots__ = '__weakref__' + +class ConfiguredBaseModel(WeakRefShimBaseModel, + validate_assignment = True, + validate_all = True, + underscore_attrs_are_private = True, + extra = "forbid", + arbitrary_types_allowed = True, + use_enum_values = True): + pass + + +class RelativeTimeEnum(str, Enum): + BEFORE = "BEFORE" + AFTER = "AFTER" + AT_SAME_TIME_AS = "AT_SAME_TIME_AS" + + +class Identified(ConfiguredBaseModel): + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + + +class Typed(ConfiguredBaseModel): + type: Literal["Typed"] = Field("Typed", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Entity(Typed): + """ + A physical, digital, conceptual, or other kind of thing with some common characteristics + """ + type: Literal["Entity"] = Field("Entity", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Intangible(Entity): + """ + An entity that is not a physical object, process, or information + """ + type: Literal["Intangible"] = Field("Intangible", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class NamedThing(Entity, Identified): + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["NamedThing"] = Field("NamedThing", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Concept(Intangible, Identified): + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Concept"] = Field("Concept", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class InformationEntity(Intangible, Identified): + """ + An entity that describes some information + """ + describes: Optional[Any] = Field(None, description="""The thing that is being described""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["InformationEntity"] = Field("InformationEntity", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class PhysicalDevice(NamedThing): + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["PhysicalDevice"] = Field("PhysicalDevice", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class StructuredValue(Intangible): + """ + A value that is a structured collection of other values + """ + type: Literal["StructuredValue"] = Field("StructuredValue", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Role(Intangible): + type: Literal["Role"] = Field("Role", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Relationship(Intangible): + type: Literal["Relationship"] = Field("Relationship", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Location(StructuredValue): + type: Literal["Location"] = Field("Location", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class PointLocation(Location): + type: Literal["PointLocation"] = Field("PointLocation", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Specification(InformationEntity): + """ + A specification of a thing + """ + describes: Optional[Any] = Field(None, description="""The thing that is being described""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Specification"] = Field("Specification", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Procedure(Specification): + """ + A canonical series of actions conducted in a certain order or manner + """ + describes: Optional[Any] = Field(None, description="""The thing that is being described""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Procedure"] = Field("Procedure", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class EntitySet(Intangible): + """ + A group of things. The collection may be heterogeneous or homogeneous. + """ + members: Optional[List[Union[Entity,Intangible,NamedThing,Event,Observation,PhysicalDevice,Concept,InformationEntity,StructuredValue,Role,Relationship,EntitySet,TimePointOrTemporalInterval,Quantity,QuantityRange,Duration,SimpleQuantity,Ratio,TemporalInterval,TimePoint,TemporalRelationship,Location,PointLocation,Specification,Procedure,QuantityKind,UnitConcept]]] = Field(default_factory=list, description="""The members of the collection""") + type: Literal["EntitySet"] = Field("EntitySet", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Event(Entity, Identified): + """ + A thing that happens + """ + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + happens_at: Optional[TimePoint] = Field(None) + has_interval: Optional[TemporalInterval] = Field(None) + has_duration: Optional[Duration] = Field(None) + is_ongoing_as_of: Optional[TimePoint] = Field(None) + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Event"] = Field("Event", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class TimePointOrTemporalInterval(Intangible): + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + type: Literal["TimePointOrTemporalInterval"] = Field("TimePointOrTemporalInterval", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class TemporalInterval(TimePointOrTemporalInterval): + """ + A period of time + """ + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + type: Literal["TemporalInterval"] = Field("TemporalInterval", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class TimePoint(TimePointOrTemporalInterval): + """ + A point in time. Can be fully specified, or specified in relative terms. + """ + year_value: Optional[int] = Field(None) + date_value: Optional[date] = Field(None) + time_value: Optional[str] = Field(None) + datetime_value: Optional[datetime ] = Field(None) + marker_event: Optional[str] = Field(None) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + type: Literal["TimePoint"] = Field("TimePoint", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class TemporalRelationship(Relationship): + """ + A relationship to another time point + """ + predicate: Optional[RelativeTimeEnum] = Field(None, description="""The relationship between the two time points""") + relative_to: Optional[Union[TemporalInterval, TimePoint, str]] = Field(None) + type: Literal["TemporalRelationship"] = Field("TemporalRelationship", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Observation(Event): + """ + A statement about the state of something + """ + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + happens_at: Optional[TimePoint] = Field(None) + has_interval: Optional[TemporalInterval] = Field(None) + has_duration: Optional[Duration] = Field(None) + is_ongoing_as_of: Optional[TimePoint] = Field(None) + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Observation"] = Field("Observation", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class QuantityKind(Concept): + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["QuantityKind"] = Field("QuantityKind", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Quantity(Intangible): + has_quantity_kind: Optional[str] = Field(None, description="""The kind of quantity""") + type: Literal["Quantity"] = Field("Quantity", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Duration(Quantity): + """ + A length of time + """ + has_quantity_kind: Optional[str] = Field(None, description="""The kind of quantity""") + type: Literal["Duration"] = Field("Duration", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class SimpleQuantity(Quantity): + """ + A quantity is a property that can be measured or counted + """ + value: Optional[float] = Field(None, description="""The value of the quantity""") + unit: Optional[str] = Field(None) + has_quantity_kind: Optional[str] = Field(None, description="""The kind of quantity""") + type: Literal["SimpleQuantity"] = Field("SimpleQuantity", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Ratio(Quantity): + """ + A tuple of two quantities + """ + numerator: Optional[Union[Quantity,Duration,SimpleQuantity,Ratio]] = Field(None, description="""The numerator of the ratio""") + denominator: Optional[Union[Quantity,Duration,SimpleQuantity,Ratio]] = Field(None, description="""The denominator of the ratio""") + has_quantity_kind: Optional[str] = Field(None, description="""The kind of quantity""") + type: Literal["Ratio"] = Field("Ratio", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class QuantityRange(Intangible): + """ + A quantity range is a property that can be measured or counted + """ + lower_bound: Optional[Union[Quantity,Duration,SimpleQuantity,Ratio]] = Field(None, description="""The lower bound of the range""") + upper_bound: Optional[Union[Quantity,Duration,SimpleQuantity,Ratio]] = Field(None, description="""The upper bound of the range""") + type: Literal["QuantityRange"] = Field("QuantityRange", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class UnitConcept(Concept): + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["UnitConcept"] = Field("UnitConcept", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +# Update forward refs +# see https://pydantic-docs.helpmanual.io/usage/postponed_annotations/ +Identified.update_forward_refs() +Typed.update_forward_refs() +Entity.update_forward_refs() +Intangible.update_forward_refs() +NamedThing.update_forward_refs() +Concept.update_forward_refs() +InformationEntity.update_forward_refs() +PhysicalDevice.update_forward_refs() +StructuredValue.update_forward_refs() +Role.update_forward_refs() +Relationship.update_forward_refs() +Location.update_forward_refs() +PointLocation.update_forward_refs() +Specification.update_forward_refs() +Procedure.update_forward_refs() +EntitySet.update_forward_refs() +Event.update_forward_refs() +TimePointOrTemporalInterval.update_forward_refs() +TemporalInterval.update_forward_refs() +TimePoint.update_forward_refs() +TemporalRelationship.update_forward_refs() +Observation.update_forward_refs() +QuantityKind.update_forward_refs() +Quantity.update_forward_refs() +Duration.update_forward_refs() +SimpleQuantity.update_forward_refs() +Ratio.update_forward_refs() +QuantityRange.update_forward_refs() +UnitConcept.update_forward_refs() + diff --git a/src/linkml_common/datamodel/social.py b/src/linkml_common/datamodel/social.py new file mode 100644 index 0000000..b63fdd3 --- /dev/null +++ b/src/linkml_common/datamodel/social.py @@ -0,0 +1,437 @@ +from __future__ import annotations +from datetime import ( + datetime, + date +) +from decimal import Decimal +from enum import Enum +import re +import sys +from typing import ( + Any, + List, + Literal, + Dict, + Optional, + Union +) +from pydantic.version import VERSION as PYDANTIC_VERSION +if int(PYDANTIC_VERSION[0])>=2: + from pydantic import ( + BaseModel, + ConfigDict, + Field, + field_validator + ) +else: + from pydantic import ( + BaseModel, + Field, + validator + ) + +metamodel_version = "None" +version = "None" + + +class WeakRefShimBaseModel(BaseModel): + __slots__ = '__weakref__' + +class ConfiguredBaseModel(WeakRefShimBaseModel, + validate_assignment = True, + validate_all = True, + underscore_attrs_are_private = True, + extra = "forbid", + arbitrary_types_allowed = True, + use_enum_values = True): + pass + + +class RelativeTimeEnum(str, Enum): + BEFORE = "BEFORE" + AFTER = "AFTER" + AT_SAME_TIME_AS = "AT_SAME_TIME_AS" + + +class HumanLanguageCodeEnum(str): + """ + An enumeration of languages + """ + pass + + +class PersonStatus(str, Enum): + # the person is living + ALIVE = "ALIVE" + # the person is deceased + DEAD = "DEAD" + # the vital status is not known + UNKNOWN = "UNKNOWN" + + +class Identified(ConfiguredBaseModel): + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + + +class Typed(ConfiguredBaseModel): + type: Literal["Typed"] = Field("Typed", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Entity(Typed): + """ + A physical, digital, conceptual, or other kind of thing with some common characteristics + """ + type: Literal["Entity"] = Field("Entity", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Intangible(Entity): + """ + An entity that is not a physical object, process, or information + """ + type: Literal["Intangible"] = Field("Intangible", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class NamedThing(Entity, Identified): + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["NamedThing"] = Field("NamedThing", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Concept(Intangible, Identified): + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Concept"] = Field("Concept", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class InformationEntity(Intangible, Identified): + """ + An entity that describes some information + """ + describes: Optional[Any] = Field(None, description="""The thing that is being described""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["InformationEntity"] = Field("InformationEntity", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class PhysicalDevice(NamedThing): + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["PhysicalDevice"] = Field("PhysicalDevice", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class StructuredValue(Intangible): + """ + A value that is a structured collection of other values + """ + type: Literal["StructuredValue"] = Field("StructuredValue", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Role(Intangible): + type: Literal["Role"] = Field("Role", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Relationship(Intangible): + type: Literal["Relationship"] = Field("Relationship", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Location(StructuredValue): + type: Literal["Location"] = Field("Location", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class PointLocation(Location): + type: Literal["PointLocation"] = Field("PointLocation", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Specification(InformationEntity): + """ + A specification of a thing + """ + describes: Optional[Any] = Field(None, description="""The thing that is being described""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Specification"] = Field("Specification", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Procedure(Specification): + """ + A canonical series of actions conducted in a certain order or manner + """ + describes: Optional[Any] = Field(None, description="""The thing that is being described""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Procedure"] = Field("Procedure", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class EntitySet(Intangible): + """ + A group of things. The collection may be heterogeneous or homogeneous. + """ + members: Optional[List[Union[Entity,Intangible,NamedThing,Event,LifeEvent,PhysicalDevice,Agent,CreativeWork,Person,Organization,AutomatedAgent,Concept,InformationEntity,StructuredValue,Role,Relationship,EntitySet,Quantity,QuantityRange,TimePointOrTemporalInterval,Service,TemporalInterval,TimePoint,SimpleQuantity,Ratio,Duration,TemporalRelationship,Location,PointLocation,Specification,Procedure,QuantityKind,UnitConcept]]] = Field(default_factory=list, description="""The members of the collection""") + type: Literal["EntitySet"] = Field("EntitySet", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class QuantityKind(Concept): + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["QuantityKind"] = Field("QuantityKind", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Quantity(Intangible): + has_quantity_kind: Optional[str] = Field(None, description="""The kind of quantity""") + type: Literal["Quantity"] = Field("Quantity", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class SimpleQuantity(Quantity): + """ + A quantity is a property that can be measured or counted + """ + value: Optional[float] = Field(None, description="""The value of the quantity""") + unit: Optional[str] = Field(None) + has_quantity_kind: Optional[str] = Field(None, description="""The kind of quantity""") + type: Literal["SimpleQuantity"] = Field("SimpleQuantity", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Ratio(Quantity): + """ + A tuple of two quantities + """ + numerator: Optional[Union[Quantity,SimpleQuantity,Ratio,Duration]] = Field(None, description="""The numerator of the ratio""") + denominator: Optional[Union[Quantity,SimpleQuantity,Ratio,Duration]] = Field(None, description="""The denominator of the ratio""") + has_quantity_kind: Optional[str] = Field(None, description="""The kind of quantity""") + type: Literal["Ratio"] = Field("Ratio", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class QuantityRange(Intangible): + """ + A quantity range is a property that can be measured or counted + """ + lower_bound: Optional[Union[Quantity,SimpleQuantity,Ratio,Duration]] = Field(None, description="""The lower bound of the range""") + upper_bound: Optional[Union[Quantity,SimpleQuantity,Ratio,Duration]] = Field(None, description="""The upper bound of the range""") + type: Literal["QuantityRange"] = Field("QuantityRange", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class UnitConcept(Concept): + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["UnitConcept"] = Field("UnitConcept", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Event(Entity, Identified): + """ + A thing that happens + """ + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + happens_at: Optional[TimePoint] = Field(None) + has_interval: Optional[TemporalInterval] = Field(None) + has_duration: Optional[Duration] = Field(None) + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Event"] = Field("Event", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class TimePointOrTemporalInterval(Intangible): + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + type: Literal["TimePointOrTemporalInterval"] = Field("TimePointOrTemporalInterval", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class TemporalInterval(TimePointOrTemporalInterval): + """ + A period of time + """ + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + type: Literal["TemporalInterval"] = Field("TemporalInterval", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class TimePoint(TimePointOrTemporalInterval): + """ + A point in time. Can be fully specified, or specified in relative terms. + """ + year_value: Optional[int] = Field(None) + date_value: Optional[date] = Field(None) + time_value: Optional[str] = Field(None) + datetime_value: Optional[datetime ] = Field(None) + marker_event: Optional[str] = Field(None) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + type: Literal["TimePoint"] = Field("TimePoint", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Duration(Quantity): + """ + A length of time + """ + has_quantity_kind: Optional[str] = Field(None, description="""The kind of quantity""") + type: Literal["Duration"] = Field("Duration", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class TemporalRelationship(Relationship): + """ + A relationship to another time point + """ + predicate: Optional[RelativeTimeEnum] = Field(None, description="""The relationship between the two time points""") + relative_to: Optional[Union[TemporalInterval, TimePoint, str]] = Field(None) + type: Literal["TemporalRelationship"] = Field("TemporalRelationship", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Agent(NamedThing): + """ + Represents an Agent + """ + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Agent"] = Field("Agent", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Person(Agent): + """ + Represents a Person + """ + primary_email: Optional[str] = Field(None, description="""The main email address of a person""") + birth_date: Optional[date] = Field(None, description="""Date on which a person is born""") + age_in_years: Optional[int] = Field(None, description="""Number of years since birth""") + vital_status: Optional[PersonStatus] = Field(None, description="""living or dead status""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Person"] = Field("Person", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + @validator('primary_email', allow_reuse=True) + def pattern_primary_email(cls, v): + pattern=re.compile(r"^\S+@[\S+\.]+\S+") + if isinstance(v,list): + for element in v: + if not pattern.match(element): + raise ValueError(f"Invalid primary_email format: {element}") + elif isinstance(v,str): + if not pattern.match(v): + raise ValueError(f"Invalid primary_email format: {v}") + return v + + +class Organization(Agent): + """ + Represents an Organization + """ + provides_services: Optional[List[Service]] = Field(default_factory=list) + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Organization"] = Field("Organization", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class AutomatedAgent(Agent): + """ + Represents an Automated Agent + """ + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["AutomatedAgent"] = Field("AutomatedAgent", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class LifeEvent(Event): + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + happens_at: Optional[TimePoint] = Field(None) + has_interval: Optional[TemporalInterval] = Field(None) + has_duration: Optional[Duration] = Field(None) + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["LifeEvent"] = Field("LifeEvent", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class CreationMetadata(ConfiguredBaseModel): + title: Optional[str] = Field(None, description="""The title of the item""") + abstract: Optional[str] = Field(None, description="""A summary of the item""") + rights: Optional[str] = Field(None, description="""Information about rights held in and over the item""") + creators: Optional[List[str]] = Field(default_factory=list, description="""The person or organization who created the work""") + contributors: Optional[List[str]] = Field(default_factory=list, description="""A person or organization that contributed to the creation of the work""") + contacts: Optional[List[str]] = Field(default_factory=list, description="""A contact point for a person or organization""") + keywords: Optional[List[str]] = Field(default_factory=list, description="""Keywords or tags used to describe this item""") + + +class CreativeWork(CreationMetadata, NamedThing): + """ + The most generic kind of creative work, including books, movies, photographs, software programs, etc. + """ + title: Optional[str] = Field(None, description="""The title of the item""") + abstract: Optional[str] = Field(None, description="""A summary of the item""") + rights: Optional[str] = Field(None, description="""Information about rights held in and over the item""") + creators: Optional[List[str]] = Field(default_factory=list, description="""The person or organization who created the work""") + contributors: Optional[List[str]] = Field(default_factory=list, description="""A person or organization that contributed to the creation of the work""") + contacts: Optional[List[str]] = Field(default_factory=list, description="""A contact point for a person or organization""") + keywords: Optional[List[str]] = Field(default_factory=list, description="""Keywords or tags used to describe this item""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["CreativeWork"] = Field("CreativeWork", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Service(Intangible): + """ + A service provided by an organization + """ + type: Literal["Service"] = Field("Service", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +# Update forward refs +# see https://pydantic-docs.helpmanual.io/usage/postponed_annotations/ +Identified.update_forward_refs() +Typed.update_forward_refs() +Entity.update_forward_refs() +Intangible.update_forward_refs() +NamedThing.update_forward_refs() +Concept.update_forward_refs() +InformationEntity.update_forward_refs() +PhysicalDevice.update_forward_refs() +StructuredValue.update_forward_refs() +Role.update_forward_refs() +Relationship.update_forward_refs() +Location.update_forward_refs() +PointLocation.update_forward_refs() +Specification.update_forward_refs() +Procedure.update_forward_refs() +EntitySet.update_forward_refs() +QuantityKind.update_forward_refs() +Quantity.update_forward_refs() +SimpleQuantity.update_forward_refs() +Ratio.update_forward_refs() +QuantityRange.update_forward_refs() +UnitConcept.update_forward_refs() +Event.update_forward_refs() +TimePointOrTemporalInterval.update_forward_refs() +TemporalInterval.update_forward_refs() +TimePoint.update_forward_refs() +Duration.update_forward_refs() +TemporalRelationship.update_forward_refs() +Agent.update_forward_refs() +Person.update_forward_refs() +Organization.update_forward_refs() +AutomatedAgent.update_forward_refs() +LifeEvent.update_forward_refs() +CreationMetadata.update_forward_refs() +CreativeWork.update_forward_refs() +Service.update_forward_refs() + diff --git a/src/linkml_common/datamodel/statistics.py b/src/linkml_common/datamodel/statistics.py new file mode 100644 index 0000000..ce2514a --- /dev/null +++ b/src/linkml_common/datamodel/statistics.py @@ -0,0 +1,784 @@ +from __future__ import annotations +from datetime import ( + datetime, + date +) +from decimal import Decimal +from enum import Enum +import re +import sys +from typing import ( + Any, + List, + Literal, + Dict, + Optional, + Union +) +from pydantic.version import VERSION as PYDANTIC_VERSION +if int(PYDANTIC_VERSION[0])>=2: + from pydantic import ( + BaseModel, + ConfigDict, + Field, + field_validator + ) +else: + from pydantic import ( + BaseModel, + Field, + validator + ) + +metamodel_version = "None" +version = "None" + + +class WeakRefShimBaseModel(BaseModel): + __slots__ = '__weakref__' + +class ConfiguredBaseModel(WeakRefShimBaseModel, + validate_assignment = True, + validate_all = True, + underscore_attrs_are_private = True, + extra = "forbid", + arbitrary_types_allowed = True, + use_enum_values = True): + pass + + +class RelativeTimeEnum(str, Enum): + BEFORE = "BEFORE" + AFTER = "AFTER" + AT_SAME_TIME_AS = "AT_SAME_TIME_AS" + + +class CaseOrControlEnum(str, Enum): + case_role_in_case_control_study = "CASE" + control_role_in_case_control_study = "CONTROL" + + +class StudyDesignEnum(str): + pass + + +class InvestigativeProtocolEnum(str): + pass + + +class SampleProcessingEnum(str): + pass + + +class HumanLanguageCodeEnum(str): + """ + An enumeration of languages + """ + pass + + +class PersonStatus(str, Enum): + # the person is living + ALIVE = "ALIVE" + # the person is deceased + DEAD = "DEAD" + # the vital status is not known + UNKNOWN = "UNKNOWN" + + +class OutcomeType(str, Enum): + # True Positive + TP = "TP" + # False Positive + FP = "FP" + # True Negative + TN = "TN" + # False Negative + FN = "FN" + + +class Identified(ConfiguredBaseModel): + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + + +class Typed(ConfiguredBaseModel): + type: Literal["Typed"] = Field("Typed", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Entity(Typed): + """ + A physical, digital, conceptual, or other kind of thing with some common characteristics + """ + type: Literal["Entity"] = Field("Entity", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Intangible(Entity): + """ + An entity that is not a physical object, process, or information + """ + type: Literal["Intangible"] = Field("Intangible", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class NamedThing(Entity, Identified): + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["NamedThing"] = Field("NamedThing", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Concept(Intangible, Identified): + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Concept"] = Field("Concept", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class InformationEntity(Intangible, Identified): + """ + An entity that describes some information + """ + describes: Optional[Any] = Field(None, description="""The thing that is being described""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["InformationEntity"] = Field("InformationEntity", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class PhysicalDevice(NamedThing): + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["PhysicalDevice"] = Field("PhysicalDevice", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class StructuredValue(Intangible): + """ + A value that is a structured collection of other values + """ + type: Literal["StructuredValue"] = Field("StructuredValue", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Role(Intangible): + type: Literal["Role"] = Field("Role", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Relationship(Intangible): + type: Literal["Relationship"] = Field("Relationship", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Location(StructuredValue): + type: Literal["Location"] = Field("Location", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class PointLocation(Location): + type: Literal["PointLocation"] = Field("PointLocation", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Specification(InformationEntity): + """ + A specification of a thing + """ + describes: Optional[Any] = Field(None, description="""The thing that is being described""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Specification"] = Field("Specification", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Procedure(Specification): + """ + A canonical series of actions conducted in a certain order or manner + """ + describes: Optional[Any] = Field(None, description="""The thing that is being described""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Procedure"] = Field("Procedure", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class EntitySet(Intangible): + """ + A group of things. The collection may be heterogeneous or homogeneous. + """ + members: Optional[List[Union[Entity,Intangible,NamedThing,Event,Investigation,LifeEvent,Observation,ExecutionOfProcedure,PlannedProcess,InvestigativeProcess,MathematicalOperationExecution,MaterialCollection,MaterialProcessing,SampleProcessing,SampleCollectionProcess,DataGenerationFromSample,Measurement,PhysicalDevice,SampleMaterial,Agent,CreativeWork,Person,Organization,AutomatedAgent,Concept,InformationEntity,StructuredValue,Role,Relationship,EntitySet,TimePointOrTemporalInterval,Service,Variable,Quantity,QuantityRange,Prediction,PredictionSummaryStatistics,SimplePrediction,AggregatePrediction,Duration,SimpleQuantity,Ratio,TemporalInterval,TimePoint,TemporalRelationship,Location,PointLocation,Specification,Publication,Dataset,Procedure,InvestigativeProtocol,StudyDesign,QuantityKind,UnitConcept]]] = Field(default_factory=list, description="""The members of the collection""") + type: Literal["EntitySet"] = Field("EntitySet", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Event(Entity, Identified): + """ + A thing that happens + """ + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + happens_at: Optional[TimePoint] = Field(None) + has_interval: Optional[TemporalInterval] = Field(None) + has_duration: Optional[Duration] = Field(None) + is_ongoing_as_of: Optional[TimePoint] = Field(None) + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Event"] = Field("Event", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class TimePointOrTemporalInterval(Intangible): + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + type: Literal["TimePointOrTemporalInterval"] = Field("TimePointOrTemporalInterval", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class TemporalInterval(TimePointOrTemporalInterval): + """ + A period of time + """ + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + type: Literal["TemporalInterval"] = Field("TemporalInterval", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class TimePoint(TimePointOrTemporalInterval): + """ + A point in time. Can be fully specified, or specified in relative terms. + """ + year_value: Optional[int] = Field(None) + date_value: Optional[date] = Field(None) + time_value: Optional[str] = Field(None) + datetime_value: Optional[datetime ] = Field(None) + marker_event: Optional[str] = Field(None) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + type: Literal["TimePoint"] = Field("TimePoint", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class TemporalRelationship(Relationship): + """ + A relationship to another time point + """ + predicate: Optional[RelativeTimeEnum] = Field(None, description="""The relationship between the two time points""") + relative_to: Optional[Union[TemporalInterval, TimePoint, str]] = Field(None) + type: Literal["TemporalRelationship"] = Field("TemporalRelationship", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Investigation(Event): + objectives: Optional[str] = Field(None) + variables: Optional[List[Variable]] = Field(default_factory=list) + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + happens_at: Optional[TimePoint] = Field(None) + has_interval: Optional[TemporalInterval] = Field(None) + has_duration: Optional[Duration] = Field(None) + is_ongoing_as_of: Optional[TimePoint] = Field(None) + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Investigation"] = Field("Investigation", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class InvestigativeProtocol(Procedure): + protocols_io_url: Optional[str] = Field(None) + describes: Optional[Any] = Field(None, description="""The thing that is being described""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["InvestigativeProtocol"] = Field("InvestigativeProtocol", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class StudyDesign(Procedure): + describes: Optional[Any] = Field(None, description="""The thing that is being described""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["StudyDesign"] = Field("StudyDesign", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class SampleMaterial(NamedThing): + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["SampleMaterial"] = Field("SampleMaterial", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Agent(NamedThing): + """ + Represents an Agent + """ + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Agent"] = Field("Agent", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Person(Agent): + """ + Represents a Person + """ + primary_email: Optional[str] = Field(None, description="""The main email address of a person""") + birth_date: Optional[date] = Field(None, description="""Date on which a person is born""") + age_in_years: Optional[int] = Field(None, description="""Number of years since birth""") + vital_status: Optional[PersonStatus] = Field(None, description="""living or dead status""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Person"] = Field("Person", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + @validator('primary_email', allow_reuse=True) + def pattern_primary_email(cls, v): + pattern=re.compile(r"^\S+@[\S+\.]+\S+") + if isinstance(v,list): + for element in v: + if not pattern.match(element): + raise ValueError(f"Invalid primary_email format: {element}") + elif isinstance(v,str): + if not pattern.match(v): + raise ValueError(f"Invalid primary_email format: {v}") + return v + + +class Organization(Agent): + """ + Represents an Organization + """ + provides_services: Optional[List[Service]] = Field(default_factory=list) + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Organization"] = Field("Organization", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class AutomatedAgent(Agent): + """ + Represents an Automated Agent + """ + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["AutomatedAgent"] = Field("AutomatedAgent", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class LifeEvent(Event): + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + happens_at: Optional[TimePoint] = Field(None) + has_interval: Optional[TemporalInterval] = Field(None) + has_duration: Optional[Duration] = Field(None) + is_ongoing_as_of: Optional[TimePoint] = Field(None) + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["LifeEvent"] = Field("LifeEvent", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class CreationMetadata(ConfiguredBaseModel): + title: Optional[str] = Field(None, description="""The title of the item""") + abstract: Optional[str] = Field(None, description="""A summary of the item""") + rights: Optional[str] = Field(None, description="""Information about rights held in and over the item""") + creators: Optional[List[str]] = Field(default_factory=list, description="""The person or organization who created the work""") + contributors: Optional[List[str]] = Field(default_factory=list, description="""A person or organization that contributed to the creation of the work""") + contacts: Optional[List[str]] = Field(default_factory=list, description="""A contact point for a person or organization""") + keywords: Optional[List[str]] = Field(default_factory=list, description="""Keywords or tags used to describe this item""") + + +class CreativeWork(CreationMetadata, NamedThing): + """ + The most generic kind of creative work, including books, movies, photographs, software programs, etc. + """ + title: Optional[str] = Field(None, description="""The title of the item""") + abstract: Optional[str] = Field(None, description="""A summary of the item""") + rights: Optional[str] = Field(None, description="""Information about rights held in and over the item""") + creators: Optional[List[str]] = Field(default_factory=list, description="""The person or organization who created the work""") + contributors: Optional[List[str]] = Field(default_factory=list, description="""A person or organization that contributed to the creation of the work""") + contacts: Optional[List[str]] = Field(default_factory=list, description="""A contact point for a person or organization""") + keywords: Optional[List[str]] = Field(default_factory=list, description="""Keywords or tags used to describe this item""") + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["CreativeWork"] = Field("CreativeWork", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Service(Intangible): + """ + A service provided by an organization + """ + type: Literal["Service"] = Field("Service", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Publication(InformationEntity): + describes: Optional[Any] = Field(None, description="""The thing that is being described""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Publication"] = Field("Publication", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Variable(Intangible): + allowed_units: Optional[List[str]] = Field(default_factory=list, description="""The units that are allowed for this variable""") + type: Literal["Variable"] = Field("Variable", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Observation(Event): + """ + A statement about the state of something + """ + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + happens_at: Optional[TimePoint] = Field(None) + has_interval: Optional[TemporalInterval] = Field(None) + has_duration: Optional[Duration] = Field(None) + is_ongoing_as_of: Optional[TimePoint] = Field(None) + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Observation"] = Field("Observation", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Measurement(Observation): + quantity_measured: Optional[Union[Quantity,Duration,SimpleQuantity,Ratio]] = Field(None, description="""The quantity being measured""") + variable_measured: Optional[Variable] = Field(None, description="""The variable being measured""") + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + happens_at: Optional[TimePoint] = Field(None) + has_interval: Optional[TemporalInterval] = Field(None) + has_duration: Optional[Duration] = Field(None) + is_ongoing_as_of: Optional[TimePoint] = Field(None) + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Measurement"] = Field("Measurement", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class QuantityKind(Concept): + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["QuantityKind"] = Field("QuantityKind", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Quantity(Intangible): + has_quantity_kind: Optional[str] = Field(None, description="""The kind of quantity""") + type: Literal["Quantity"] = Field("Quantity", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Duration(Quantity): + """ + A length of time + """ + has_quantity_kind: Optional[str] = Field(None, description="""The kind of quantity""") + type: Literal["Duration"] = Field("Duration", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class SimpleQuantity(Quantity): + """ + A quantity is a property that can be measured or counted + """ + value: Optional[float] = Field(None, description="""The value of the quantity""") + unit: Optional[str] = Field(None) + has_quantity_kind: Optional[str] = Field(None, description="""The kind of quantity""") + type: Literal["SimpleQuantity"] = Field("SimpleQuantity", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Ratio(Quantity): + """ + A tuple of two quantities + """ + numerator: Optional[Union[Quantity,Duration,SimpleQuantity,Ratio]] = Field(None, description="""The numerator of the ratio""") + denominator: Optional[Union[Quantity,Duration,SimpleQuantity,Ratio]] = Field(None, description="""The denominator of the ratio""") + has_quantity_kind: Optional[str] = Field(None, description="""The kind of quantity""") + type: Literal["Ratio"] = Field("Ratio", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class QuantityRange(Intangible): + """ + A quantity range is a property that can be measured or counted + """ + lower_bound: Optional[Union[Quantity,Duration,SimpleQuantity,Ratio]] = Field(None, description="""The lower bound of the range""") + upper_bound: Optional[Union[Quantity,Duration,SimpleQuantity,Ratio]] = Field(None, description="""The upper bound of the range""") + type: Literal["QuantityRange"] = Field("QuantityRange", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class UnitConcept(Concept): + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["UnitConcept"] = Field("UnitConcept", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class ExecutionOfProcedure(Event): + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + happens_at: Optional[TimePoint] = Field(None) + has_interval: Optional[TemporalInterval] = Field(None) + has_duration: Optional[Duration] = Field(None) + is_ongoing_as_of: Optional[TimePoint] = Field(None) + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["ExecutionOfProcedure"] = Field("ExecutionOfProcedure", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class PlannedProcess(ExecutionOfProcedure): + """ + A process that follows a defined procedure or plan + """ + follows_procedure: Optional[str] = Field(None) + uses_physical_device: Optional[str] = Field(None) + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + happens_at: Optional[TimePoint] = Field(None) + has_interval: Optional[TemporalInterval] = Field(None) + has_duration: Optional[Duration] = Field(None) + is_ongoing_as_of: Optional[TimePoint] = Field(None) + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["PlannedProcess"] = Field("PlannedProcess", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class InvestigativeProcess(PlannedProcess): + follows_procedure: Optional[str] = Field(None) + part_of: Optional[str] = Field(None) + uses_physical_device: Optional[str] = Field(None) + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + happens_at: Optional[TimePoint] = Field(None) + has_interval: Optional[TemporalInterval] = Field(None) + has_duration: Optional[Duration] = Field(None) + is_ongoing_as_of: Optional[TimePoint] = Field(None) + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["InvestigativeProcess"] = Field("InvestigativeProcess", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class SampleCollectionProcess(InvestigativeProcess): + material_collected: Optional[str] = Field(None) + collected_from: Optional[str] = Field(None) + follows_procedure: Optional[str] = Field(None) + part_of: Optional[str] = Field(None) + uses_physical_device: Optional[str] = Field(None) + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + happens_at: Optional[TimePoint] = Field(None) + has_interval: Optional[TemporalInterval] = Field(None) + has_duration: Optional[Duration] = Field(None) + is_ongoing_as_of: Optional[TimePoint] = Field(None) + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["SampleCollectionProcess"] = Field("SampleCollectionProcess", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class DataGenerationFromSample(InvestigativeProcess): + follows_procedure: Optional[str] = Field(None) + part_of: Optional[str] = Field(None) + uses_physical_device: Optional[str] = Field(None) + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + happens_at: Optional[TimePoint] = Field(None) + has_interval: Optional[TemporalInterval] = Field(None) + has_duration: Optional[Duration] = Field(None) + is_ongoing_as_of: Optional[TimePoint] = Field(None) + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["DataGenerationFromSample"] = Field("DataGenerationFromSample", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class MathematicalOperationExecution(PlannedProcess): + """ + Application of a mathematical operation to one or more inputs to produce one or more outputs + """ + inputs: Optional[List[Any]] = Field(default_factory=list, description="""The inputs to the operation""") + outputs: Optional[List[Any]] = Field(default_factory=list, description="""The outputs of the operation""") + parts: Optional[List[str]] = Field(default_factory=list, description="""The parts of the process""") + immediate_preceding_steps: Optional[List[str]] = Field(default_factory=list, description="""The steps that immediately precede this step""") + follows_procedure: Optional[str] = Field(None) + uses_physical_device: Optional[str] = Field(None) + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + happens_at: Optional[TimePoint] = Field(None) + has_interval: Optional[TemporalInterval] = Field(None) + has_duration: Optional[Duration] = Field(None) + is_ongoing_as_of: Optional[TimePoint] = Field(None) + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["MathematicalOperationExecution"] = Field("MathematicalOperationExecution", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class MaterialCollection(PlannedProcess): + follows_procedure: Optional[str] = Field(None) + uses_physical_device: Optional[str] = Field(None) + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + happens_at: Optional[TimePoint] = Field(None) + has_interval: Optional[TemporalInterval] = Field(None) + has_duration: Optional[Duration] = Field(None) + is_ongoing_as_of: Optional[TimePoint] = Field(None) + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["MaterialCollection"] = Field("MaterialCollection", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class MaterialProcessing(PlannedProcess): + follows_procedure: Optional[str] = Field(None) + uses_physical_device: Optional[str] = Field(None) + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + happens_at: Optional[TimePoint] = Field(None) + has_interval: Optional[TemporalInterval] = Field(None) + has_duration: Optional[Duration] = Field(None) + is_ongoing_as_of: Optional[TimePoint] = Field(None) + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["MaterialProcessing"] = Field("MaterialProcessing", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class SampleProcessing(MaterialProcessing): + follows_procedure: Optional[str] = Field(None) + uses_physical_device: Optional[str] = Field(None) + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + happens_at: Optional[TimePoint] = Field(None) + has_interval: Optional[TemporalInterval] = Field(None) + has_duration: Optional[Duration] = Field(None) + is_ongoing_as_of: Optional[TimePoint] = Field(None) + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["SampleProcessing"] = Field("SampleProcessing", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Dataset(CreationMetadata, InformationEntity): + collected_as_part_of: Optional[List[str]] = Field(default_factory=list) + title: Optional[str] = Field(None, description="""The title of the item""") + abstract: Optional[str] = Field(None, description="""A summary of the item""") + rights: Optional[str] = Field(None, description="""Information about rights held in and over the item""") + creators: Optional[List[str]] = Field(default_factory=list, description="""The person or organization who created the work""") + contributors: Optional[List[str]] = Field(default_factory=list, description="""A person or organization that contributed to the creation of the work""") + contacts: Optional[List[str]] = Field(default_factory=list, description="""A contact point for a person or organization""") + keywords: Optional[List[str]] = Field(default_factory=list, description="""Keywords or tags used to describe this item""") + describes: Optional[Any] = Field(None, description="""The thing that is being described""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Dataset"] = Field("Dataset", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Prediction(Intangible): + variable_predicted: Optional[Variable] = Field(None) + predicted_value: Optional[Any] = Field(None) + expected_value: Optional[Any] = Field(None) + type: Literal["Prediction"] = Field("Prediction", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class SimplePrediction(Prediction): + outcome: Optional[OutcomeType] = Field(None) + expected_value: Optional[Union[float, int, str]] = Field(None) + variable_predicted: Optional[Variable] = Field(None) + predicted_value: Optional[Any] = Field(None) + type: Literal["SimplePrediction"] = Field("SimplePrediction", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class OutcomeStatistics(ConfiguredBaseModel): + """ + A class for collecting totals of various outcomes. + """ + true_positive_count: Optional[int] = Field(None, description="""Total number of true positives (TP)""") + false_positive_count: Optional[int] = Field(None, description="""Total number of false positives (FP)""") + true_negative_count: Optional[int] = Field(None, description="""Total number of true negatives (TN)""") + false_negative_count: Optional[int] = Field(None, description="""Total number of false negatives (FN)""") + recall: Optional[float] = Field(None, description="""Recall is calculated as TP / (TP + FN)""") + precision: Optional[float] = Field(None, description="""Precision is calculated as TP / (TP + FP)""") + f1_score: Optional[float] = Field(None, description="""F1 Score is the harmonic mean of precision and recall""") + accuracy: Optional[float] = Field(None, description="""Accuracy is calculated as (TP + TN) / (TP + FP + TN + FN)""") + + +class AggregatePrediction(OutcomeStatistics, Prediction): + true_positive_count: Optional[int] = Field(None, description="""Total number of true positives (TP)""") + false_positive_count: Optional[int] = Field(None, description="""Total number of false positives (FP)""") + true_negative_count: Optional[int] = Field(None, description="""Total number of true negatives (TN)""") + false_negative_count: Optional[int] = Field(None, description="""Total number of false negatives (FN)""") + recall: Optional[float] = Field(None, description="""Recall is calculated as TP / (TP + FN)""") + precision: Optional[float] = Field(None, description="""Precision is calculated as TP / (TP + FP)""") + f1_score: Optional[float] = Field(None, description="""F1 Score is the harmonic mean of precision and recall""") + accuracy: Optional[float] = Field(None, description="""Accuracy is calculated as (TP + TN) / (TP + FP + TN + FN)""") + variable_predicted: Optional[Variable] = Field(None) + predicted_value: Optional[Any] = Field(None) + expected_value: Optional[Any] = Field(None) + type: Literal["AggregatePrediction"] = Field("AggregatePrediction", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class PredictionSummaryStatistics(OutcomeStatistics, Intangible): + """ + A class for collecting totals of various outcomes. + """ + predictions: Optional[List[Union[Prediction,SimplePrediction,AggregatePrediction]]] = Field(default_factory=list) + uses_dataset: Optional[str] = Field(None) + true_positive_count: Optional[int] = Field(None, description="""Total number of true positives (TP)""") + false_positive_count: Optional[int] = Field(None, description="""Total number of false positives (FP)""") + true_negative_count: Optional[int] = Field(None, description="""Total number of true negatives (TN)""") + false_negative_count: Optional[int] = Field(None, description="""Total number of false negatives (FN)""") + recall: Optional[float] = Field(None, description="""Recall is calculated as TP / (TP + FN)""") + precision: Optional[float] = Field(None, description="""Precision is calculated as TP / (TP + FP)""") + f1_score: Optional[float] = Field(None, description="""F1 Score is the harmonic mean of precision and recall""") + accuracy: Optional[float] = Field(None, description="""Accuracy is calculated as (TP + TN) / (TP + FP + TN + FN)""") + type: Literal["PredictionSummaryStatistics"] = Field("PredictionSummaryStatistics", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +# Update forward refs +# see https://pydantic-docs.helpmanual.io/usage/postponed_annotations/ +Identified.update_forward_refs() +Typed.update_forward_refs() +Entity.update_forward_refs() +Intangible.update_forward_refs() +NamedThing.update_forward_refs() +Concept.update_forward_refs() +InformationEntity.update_forward_refs() +PhysicalDevice.update_forward_refs() +StructuredValue.update_forward_refs() +Role.update_forward_refs() +Relationship.update_forward_refs() +Location.update_forward_refs() +PointLocation.update_forward_refs() +Specification.update_forward_refs() +Procedure.update_forward_refs() +EntitySet.update_forward_refs() +Event.update_forward_refs() +TimePointOrTemporalInterval.update_forward_refs() +TemporalInterval.update_forward_refs() +TimePoint.update_forward_refs() +TemporalRelationship.update_forward_refs() +Investigation.update_forward_refs() +InvestigativeProtocol.update_forward_refs() +StudyDesign.update_forward_refs() +SampleMaterial.update_forward_refs() +Agent.update_forward_refs() +Person.update_forward_refs() +Organization.update_forward_refs() +AutomatedAgent.update_forward_refs() +LifeEvent.update_forward_refs() +CreationMetadata.update_forward_refs() +CreativeWork.update_forward_refs() +Service.update_forward_refs() +Publication.update_forward_refs() +Variable.update_forward_refs() +Observation.update_forward_refs() +Measurement.update_forward_refs() +QuantityKind.update_forward_refs() +Quantity.update_forward_refs() +Duration.update_forward_refs() +SimpleQuantity.update_forward_refs() +Ratio.update_forward_refs() +QuantityRange.update_forward_refs() +UnitConcept.update_forward_refs() +ExecutionOfProcedure.update_forward_refs() +PlannedProcess.update_forward_refs() +InvestigativeProcess.update_forward_refs() +SampleCollectionProcess.update_forward_refs() +DataGenerationFromSample.update_forward_refs() +MathematicalOperationExecution.update_forward_refs() +MaterialCollection.update_forward_refs() +MaterialProcessing.update_forward_refs() +SampleProcessing.update_forward_refs() +Dataset.update_forward_refs() +Prediction.update_forward_refs() +SimplePrediction.update_forward_refs() +OutcomeStatistics.update_forward_refs() +AggregatePrediction.update_forward_refs() +PredictionSummaryStatistics.update_forward_refs() + diff --git a/src/linkml_common/datamodel/time.py b/src/linkml_common/datamodel/time.py new file mode 100644 index 0000000..80717fd --- /dev/null +++ b/src/linkml_common/datamodel/time.py @@ -0,0 +1,318 @@ +from __future__ import annotations +from datetime import ( + datetime, + date +) +from decimal import Decimal +from enum import Enum +import re +import sys +from typing import ( + Any, + List, + Literal, + Dict, + Optional, + Union +) +from pydantic.version import VERSION as PYDANTIC_VERSION +if int(PYDANTIC_VERSION[0])>=2: + from pydantic import ( + BaseModel, + ConfigDict, + Field, + field_validator + ) +else: + from pydantic import ( + BaseModel, + Field, + validator + ) + +metamodel_version = "None" +version = "None" + + +class WeakRefShimBaseModel(BaseModel): + __slots__ = '__weakref__' + +class ConfiguredBaseModel(WeakRefShimBaseModel, + validate_assignment = True, + validate_all = True, + underscore_attrs_are_private = True, + extra = "forbid", + arbitrary_types_allowed = True, + use_enum_values = True): + pass + + +class RelativeTimeEnum(str, Enum): + BEFORE = "BEFORE" + AFTER = "AFTER" + AT_SAME_TIME_AS = "AT_SAME_TIME_AS" + + +class Identified(ConfiguredBaseModel): + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + + +class Typed(ConfiguredBaseModel): + type: Literal["Typed"] = Field("Typed", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Entity(Typed): + """ + A physical, digital, conceptual, or other kind of thing with some common characteristics + """ + type: Literal["Entity"] = Field("Entity", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Intangible(Entity): + """ + An entity that is not a physical object, process, or information + """ + type: Literal["Intangible"] = Field("Intangible", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class NamedThing(Entity, Identified): + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["NamedThing"] = Field("NamedThing", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Concept(Intangible, Identified): + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Concept"] = Field("Concept", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class InformationEntity(Intangible, Identified): + """ + An entity that describes some information + """ + describes: Optional[Any] = Field(None, description="""The thing that is being described""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["InformationEntity"] = Field("InformationEntity", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class PhysicalDevice(NamedThing): + classification: Optional[str] = Field(None, description="""A precise classification of the thing, using a concept from an ontology, controlled vocabulary, thesaurus, or taxonomy. Some schema classes may choose to restrict the range of values which this slot can take, using `values_from`, or bindings.""") + ontology_types: Optional[List[str]] = Field(default_factory=list) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["PhysicalDevice"] = Field("PhysicalDevice", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class StructuredValue(Intangible): + """ + A value that is a structured collection of other values + """ + type: Literal["StructuredValue"] = Field("StructuredValue", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Role(Intangible): + type: Literal["Role"] = Field("Role", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Relationship(Intangible): + type: Literal["Relationship"] = Field("Relationship", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Location(StructuredValue): + type: Literal["Location"] = Field("Location", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class PointLocation(Location): + type: Literal["PointLocation"] = Field("PointLocation", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Specification(InformationEntity): + """ + A specification of a thing + """ + describes: Optional[Any] = Field(None, description="""The thing that is being described""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Specification"] = Field("Specification", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Procedure(Specification): + """ + A canonical series of actions conducted in a certain order or manner + """ + describes: Optional[Any] = Field(None, description="""The thing that is being described""") + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Procedure"] = Field("Procedure", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class EntitySet(Intangible): + """ + A group of things. The collection may be heterogeneous or homogeneous. + """ + members: Optional[List[Union[Entity,Intangible,NamedThing,Event,Observation,PhysicalDevice,Concept,InformationEntity,StructuredValue,Role,Relationship,EntitySet,Quantity,QuantityRange,TimePointOrTemporalInterval,TemporalInterval,TimePoint,SimpleQuantity,Ratio,Duration,TemporalRelationship,Location,PointLocation,Specification,Procedure,QuantityKind,UnitConcept]]] = Field(default_factory=list, description="""The members of the collection""") + type: Literal["EntitySet"] = Field("EntitySet", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class QuantityKind(Concept): + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["QuantityKind"] = Field("QuantityKind", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Quantity(Intangible): + has_quantity_kind: Optional[str] = Field(None, description="""The kind of quantity""") + type: Literal["Quantity"] = Field("Quantity", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class SimpleQuantity(Quantity): + """ + A quantity is a property that can be measured or counted + """ + value: Optional[float] = Field(None, description="""The value of the quantity""") + unit: Optional[str] = Field(None) + has_quantity_kind: Optional[str] = Field(None, description="""The kind of quantity""") + type: Literal["SimpleQuantity"] = Field("SimpleQuantity", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Ratio(Quantity): + """ + A tuple of two quantities + """ + numerator: Optional[Union[Quantity,SimpleQuantity,Ratio,Duration]] = Field(None, description="""The numerator of the ratio""") + denominator: Optional[Union[Quantity,SimpleQuantity,Ratio,Duration]] = Field(None, description="""The denominator of the ratio""") + has_quantity_kind: Optional[str] = Field(None, description="""The kind of quantity""") + type: Literal["Ratio"] = Field("Ratio", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class QuantityRange(Intangible): + """ + A quantity range is a property that can be measured or counted + """ + lower_bound: Optional[Union[Quantity,SimpleQuantity,Ratio,Duration]] = Field(None, description="""The lower bound of the range""") + upper_bound: Optional[Union[Quantity,SimpleQuantity,Ratio,Duration]] = Field(None, description="""The upper bound of the range""") + type: Literal["QuantityRange"] = Field("QuantityRange", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class UnitConcept(Concept): + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["UnitConcept"] = Field("UnitConcept", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Event(Entity, Identified): + """ + A thing that happens + """ + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + happens_at: Optional[TimePoint] = Field(None) + has_interval: Optional[TemporalInterval] = Field(None) + has_duration: Optional[Duration] = Field(None) + is_ongoing_as_of: Optional[TimePoint] = Field(None) + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Event"] = Field("Event", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Observation(Event): + """ + A statement about the state of something + """ + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + happens_at: Optional[TimePoint] = Field(None) + has_interval: Optional[TemporalInterval] = Field(None) + has_duration: Optional[Duration] = Field(None) + is_ongoing_as_of: Optional[TimePoint] = Field(None) + id: str = Field(..., description="""A unique identifier for a thing""") + name: Optional[str] = Field(None, description="""A human-readable name for a thing""") + type: Literal["Observation"] = Field("Observation", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class TimePointOrTemporalInterval(Intangible): + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + type: Literal["TimePointOrTemporalInterval"] = Field("TimePointOrTemporalInterval", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class TemporalInterval(TimePointOrTemporalInterval): + """ + A period of time + """ + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + type: Literal["TemporalInterval"] = Field("TemporalInterval", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class TimePoint(TimePointOrTemporalInterval): + """ + A point in time. Can be fully specified, or specified in relative terms. + """ + year_value: Optional[int] = Field(None) + date_value: Optional[date] = Field(None) + time_value: Optional[str] = Field(None) + datetime_value: Optional[datetime ] = Field(None) + marker_event: Optional[str] = Field(None) + description: Optional[str] = Field(None, description="""A human-readable description for a thing""") + starts_at: Optional[TimePoint] = Field(None) + ends_at: Optional[TimePoint] = Field(None) + type: Literal["TimePoint"] = Field("TimePoint", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class Duration(Quantity): + """ + A length of time + """ + has_quantity_kind: Optional[str] = Field(None, description="""The kind of quantity""") + type: Literal["Duration"] = Field("Duration", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +class TemporalRelationship(Relationship): + """ + A relationship to another time point + """ + predicate: Optional[RelativeTimeEnum] = Field(None, description="""The relationship between the two time points""") + relative_to: Optional[Union[TemporalInterval, TimePoint, str]] = Field(None) + type: Literal["TemporalRelationship"] = Field("TemporalRelationship", description="""A type for a thing. The range of this should be a class within the schema. It is intended for schema-based classification. Anything beneath the shoreline of the schema should use `classification`.""") + + +# Update forward refs +# see https://pydantic-docs.helpmanual.io/usage/postponed_annotations/ +Identified.update_forward_refs() +Typed.update_forward_refs() +Entity.update_forward_refs() +Intangible.update_forward_refs() +NamedThing.update_forward_refs() +Concept.update_forward_refs() +InformationEntity.update_forward_refs() +PhysicalDevice.update_forward_refs() +StructuredValue.update_forward_refs() +Role.update_forward_refs() +Relationship.update_forward_refs() +Location.update_forward_refs() +PointLocation.update_forward_refs() +Specification.update_forward_refs() +Procedure.update_forward_refs() +EntitySet.update_forward_refs() +QuantityKind.update_forward_refs() +Quantity.update_forward_refs() +SimpleQuantity.update_forward_refs() +Ratio.update_forward_refs() +QuantityRange.update_forward_refs() +UnitConcept.update_forward_refs() +Event.update_forward_refs() +Observation.update_forward_refs() +TimePointOrTemporalInterval.update_forward_refs() +TemporalInterval.update_forward_refs() +TimePoint.update_forward_refs() +Duration.update_forward_refs() +TemporalRelationship.update_forward_refs() +