Core models
Represent shared concepts, codes, and extensions with GKM-Core models.
GKM Core Class Definitions
GKMCoreMetadataMixin
Bases: GKMMetadataMixin
Provide gkm-core model metadata.
schema_id
classmethod
Return the canonical JSON Schema identifier for the model.
Returns:
| Type | Description |
|---|---|
str
|
Canonical schema URI. |
maturity
classmethod
Return the GKM maturity level for the model.
Returns:
| Type | Description |
|---|---|
Maturity
|
Declared maturity level. |
apply_schema_metadata
classmethod
Add GKM metadata to a generated JSON Schema.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
schema
|
dict[str, Any]
|
Generated JSON Schema to mutate in place. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
The annotated JSON Schema. |
model_json_schema
classmethod
model_json_schema(
by_alias: bool = True,
ref_template: str = "#/$defs/{model}",
schema_generator: type[
GenerateJsonSchema
] = GenerateJsonSchema,
mode: JsonSchemaMode = "validation",
*,
union_format: Literal[
"any_of", "primitive_type_array"
] = "any_of",
) -> dict[str, Any]
Generate JSON Schema with GKM metadata.
Default values follow Pydantic defaults.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
by_alias
|
bool
|
Whether to use field aliases. |
True
|
ref_template
|
str
|
Template for schema references. |
'#/$defs/{model}'
|
schema_generator
|
type[GenerateJsonSchema]
|
Pydantic schema generator class. |
GenerateJsonSchema
|
mode
|
JsonSchemaMode
|
Pydantic schema generation mode. |
'validation'
|
union_format
|
Literal['any_of', 'primitive_type_array']
|
How to represent unions; ignored on Pydantic versions older than 2.12. |
'any_of'
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
JSON Schema annotated with GKM metadata. |
GKSCoreMetadataMixin
Bases: GKMCoreMetadataMixin
Deprecated alias for :class:GKMCoreMetadataMixin.
schema_id
classmethod
Return the canonical JSON Schema identifier for the model.
Returns:
| Type | Description |
|---|---|
str
|
Canonical schema URI. |
maturity
classmethod
Return the GKM maturity level for the model.
Returns:
| Type | Description |
|---|---|
Maturity
|
Declared maturity level. |
apply_schema_metadata
classmethod
Add GKM metadata to a generated JSON Schema.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
schema
|
dict[str, Any]
|
Generated JSON Schema to mutate in place. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
The annotated JSON Schema. |
model_json_schema
classmethod
model_json_schema(
by_alias: bool = True,
ref_template: str = "#/$defs/{model}",
schema_generator: type[
GenerateJsonSchema
] = GenerateJsonSchema,
mode: JsonSchemaMode = "validation",
*,
union_format: Literal[
"any_of", "primitive_type_array"
] = "any_of",
) -> dict[str, Any]
Generate JSON Schema with GKM metadata.
Default values follow Pydantic defaults.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
by_alias
|
bool
|
Whether to use field aliases. |
True
|
ref_template
|
str
|
Template for schema references. |
'#/$defs/{model}'
|
schema_generator
|
type[GenerateJsonSchema]
|
Pydantic schema generator class. |
GenerateJsonSchema
|
mode
|
JsonSchemaMode
|
Pydantic schema generation mode. |
'validation'
|
union_format
|
Literal['any_of', 'primitive_type_array']
|
How to represent unions; ignored on Pydantic versions older than 2.12. |
'any_of'
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
JSON Schema annotated with GKM metadata. |
BaseModelForbidExtra
Relation
Bases: str, Enum
A mapping relation between concepts as defined by the Simple Knowledge Organization System (SKOS).
MembershipOperator
Bases: str, Enum
The logical relationship between concepts in the set, in the context of some knowledge reported about them.
The value 'AND' indicates that the concepts are dependent and occur together in this context - i.e. the reported assertion is not necessarily true for each concept on its own - only in combination with the other(s). The value 'OR' indicates that each concept applies independently in this context - i.e. the reported assertion is necessarily true for each concept on its own, independent of the presence of the other(s).
code
Bases: GKMCoreMetadataMixin, RootModel
Indicates that the value is taken from a set of controlled strings defined elsewhere. Technically, a code is restricted to a string which has at least one character and no leading or trailing whitespace, and where there is no whitespace other than single spaces in the contents.
root
class-attribute
instance-attribute
root: Annotated[
str, StringConstraints(pattern="\\S+( \\S+)*")
] = Field(
...,
json_schema_extra={
"description": "Indicates that the value is taken from a set of controlled strings defined elsewhere. Technically, a code is restricted to a string which has at least one character and no leading or trailing whitespace, and where there is no whitespace other than single spaces in the contents.",
"example": "ENSG00000139618",
},
)
schema_id
classmethod
Return the canonical JSON Schema identifier for the model.
Returns:
| Type | Description |
|---|---|
str
|
Canonical schema URI. |
maturity
classmethod
Return the GKM maturity level for the model.
Returns:
| Type | Description |
|---|---|
Maturity
|
Declared maturity level. |
apply_schema_metadata
classmethod
Add GKM metadata to a generated JSON Schema.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
schema
|
dict[str, Any]
|
Generated JSON Schema to mutate in place. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
The annotated JSON Schema. |
model_json_schema
classmethod
model_json_schema(
by_alias: bool = True,
ref_template: str = "#/$defs/{model}",
schema_generator: type[
GenerateJsonSchema
] = GenerateJsonSchema,
mode: JsonSchemaMode = "validation",
*,
union_format: Literal[
"any_of", "primitive_type_array"
] = "any_of",
) -> dict[str, Any]
Generate JSON Schema with GKM metadata.
Default values follow Pydantic defaults.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
by_alias
|
bool
|
Whether to use field aliases. |
True
|
ref_template
|
str
|
Template for schema references. |
'#/$defs/{model}'
|
schema_generator
|
type[GenerateJsonSchema]
|
Pydantic schema generator class. |
GenerateJsonSchema
|
mode
|
JsonSchemaMode
|
Pydantic schema generation mode. |
'validation'
|
union_format
|
Literal['any_of', 'primitive_type_array']
|
How to represent unions; ignored on Pydantic versions older than 2.12. |
'any_of'
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
JSON Schema annotated with GKM metadata. |
iriReference
Bases: GKMCoreMetadataMixin, RootModel
An IRI Reference (either an IRI or a relative-reference), according to RFC3986 section 4.1 <https://datatracker.ietf.org/doc/html/rfc3986#section-4.1>_ and RFC3987 section 2.1 <https://datatracker.ietf.org/doc/html/rfc3987#section-2.1>. MAY be a JSON Pointer as an IRI fragment, as described by RFC6901 section 6 <https://datatracker.ietf.org/doc/html/rfc6901#section-6>.
root
class-attribute
instance-attribute
root: str = Field(
...,
json_schema_extra={
"description": "An IRI Reference (either an IRI or a relative-reference), according to `RFC3986 section 4.1 <https://datatracker.ietf.org/doc/html/rfc3986#section-4.1>`_ and `RFC3987 section 2.1 <https://datatracker.ietf.org/doc/html/rfc3987#section-2.1>`_. MAY be a JSON Pointer as an IRI fragment, as described by `RFC6901 section 6 <https://datatracker.ietf.org/doc/html/rfc6901#section-6>`_."
},
)
__hash__
Hash the underlying IRI.
Returns:
| Type | Description |
|---|---|
int
|
Hash of the underlying value. |
ga4gh_serialize
Serialize an IRI reference for GA4GH digest computation.
Returns:
| Type | Description |
|---|---|
str
|
Digest for a GA4GH reference, otherwise the original IRI. |
schema_id
classmethod
Return the canonical JSON Schema identifier for the model.
Returns:
| Type | Description |
|---|---|
str
|
Canonical schema URI. |
maturity
classmethod
Return the GKM maturity level for the model.
Returns:
| Type | Description |
|---|---|
Maturity
|
Declared maturity level. |
apply_schema_metadata
classmethod
Add GKM metadata to a generated JSON Schema.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
schema
|
dict[str, Any]
|
Generated JSON Schema to mutate in place. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
The annotated JSON Schema. |
model_json_schema
classmethod
model_json_schema(
by_alias: bool = True,
ref_template: str = "#/$defs/{model}",
schema_generator: type[
GenerateJsonSchema
] = GenerateJsonSchema,
mode: JsonSchemaMode = "validation",
*,
union_format: Literal[
"any_of", "primitive_type_array"
] = "any_of",
) -> dict[str, Any]
Generate JSON Schema with GKM metadata.
Default values follow Pydantic defaults.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
by_alias
|
bool
|
Whether to use field aliases. |
True
|
ref_template
|
str
|
Template for schema references. |
'#/$defs/{model}'
|
schema_generator
|
type[GenerateJsonSchema]
|
Pydantic schema generator class. |
GenerateJsonSchema
|
mode
|
JsonSchemaMode
|
Pydantic schema generation mode. |
'validation'
|
union_format
|
Literal['any_of', 'primitive_type_array']
|
How to represent unions; ignored on Pydantic versions older than 2.12. |
'any_of'
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
JSON Schema annotated with GKM metadata. |
Element
Bases: GKMCoreMetadataMixin, BaseModel
The base definition for all identifiable data objects.
id
class-attribute
instance-attribute
id: str | None = Field(
default=None,
description="The 'logical' identifier of the data element in the system of record, e.g. a UUID. This 'id' is unique within a given system, but may or may not be globally unique outside the system. It is used within a system to reference an object from another.",
)
extensions
class-attribute
instance-attribute
extensions: list[Extension] | None = Field(
default=None,
description="A list of extensions to the Entity, that allow for capture of information not directly supported by elements defined in the model.",
)
get_extensions_by_name
get_extensions_by_name(name: str) -> list[Extension]
Fetch all contained extension exactly matching the provided name
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
name of extension to fetch |
required |
Returns:
| Type | Description |
|---|---|
list[Extension]
|
a list of all matching extensions, empty if no matches found (or if instance contains no extensions) |
schema_id
classmethod
Return the canonical JSON Schema identifier for the model.
Returns:
| Type | Description |
|---|---|
str
|
Canonical schema URI. |
maturity
classmethod
Return the GKM maturity level for the model.
Returns:
| Type | Description |
|---|---|
Maturity
|
Declared maturity level. |
apply_schema_metadata
classmethod
Add GKM metadata to a generated JSON Schema.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
schema
|
dict[str, Any]
|
Generated JSON Schema to mutate in place. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
The annotated JSON Schema. |
model_json_schema
classmethod
model_json_schema(
by_alias: bool = True,
ref_template: str = "#/$defs/{model}",
schema_generator: type[
GenerateJsonSchema
] = GenerateJsonSchema,
mode: JsonSchemaMode = "validation",
*,
union_format: Literal[
"any_of", "primitive_type_array"
] = "any_of",
) -> dict[str, Any]
Generate JSON Schema with GKM metadata.
Default values follow Pydantic defaults.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
by_alias
|
bool
|
Whether to use field aliases. |
True
|
ref_template
|
str
|
Template for schema references. |
'#/$defs/{model}'
|
schema_generator
|
type[GenerateJsonSchema]
|
Pydantic schema generator class. |
GenerateJsonSchema
|
mode
|
JsonSchemaMode
|
Pydantic schema generation mode. |
'validation'
|
union_format
|
Literal['any_of', 'primitive_type_array']
|
How to represent unions; ignored on Pydantic versions older than 2.12. |
'any_of'
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
JSON Schema annotated with GKM metadata. |
Extension
Bases: Element, BaseModelForbidExtra
The Extension class provides entities with a means to include additional attributes that are outside of the specified standard but needed by a given content provider or system implementer. These extensions are not expected to be natively understood, but may be used for pre-negotiated exchange of message attributes between systems.
name
class-attribute
instance-attribute
name: str = Field(
...,
description="A name for the Extension. Should be indicative of its meaning and/or the type of information it value represents.",
)
value
class-attribute
instance-attribute
value: (
int
| float
| str
| bool
| dict[str, Any]
| list[Any]
| None
) = Field(
...,
description="The value of the Extension - can be any primitive or structured object",
)
description
class-attribute
instance-attribute
description: str | None = Field(
default=None,
description="A description of the meaning or utility of the Extension, to explain the type of information it is meant to hold.",
)
id
class-attribute
instance-attribute
id: str | None = Field(
default=None,
description="The 'logical' identifier of the data element in the system of record, e.g. a UUID. This 'id' is unique within a given system, but may or may not be globally unique outside the system. It is used within a system to reference an object from another.",
)
extensions
class-attribute
instance-attribute
extensions: list[Extension] | None = Field(
default=None,
description="A list of extensions to the Entity, that allow for capture of information not directly supported by elements defined in the model.",
)
schema_id
classmethod
Return the canonical JSON Schema identifier for the model.
Returns:
| Type | Description |
|---|---|
str
|
Canonical schema URI. |
maturity
classmethod
Return the GKM maturity level for the model.
Returns:
| Type | Description |
|---|---|
Maturity
|
Declared maturity level. |
apply_schema_metadata
classmethod
Add GKM metadata to a generated JSON Schema.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
schema
|
dict[str, Any]
|
Generated JSON Schema to mutate in place. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
The annotated JSON Schema. |
model_json_schema
classmethod
model_json_schema(
by_alias: bool = True,
ref_template: str = "#/$defs/{model}",
schema_generator: type[
GenerateJsonSchema
] = GenerateJsonSchema,
mode: JsonSchemaMode = "validation",
*,
union_format: Literal[
"any_of", "primitive_type_array"
] = "any_of",
) -> dict[str, Any]
Generate JSON Schema with GKM metadata.
Default values follow Pydantic defaults.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
by_alias
|
bool
|
Whether to use field aliases. |
True
|
ref_template
|
str
|
Template for schema references. |
'#/$defs/{model}'
|
schema_generator
|
type[GenerateJsonSchema]
|
Pydantic schema generator class. |
GenerateJsonSchema
|
mode
|
JsonSchemaMode
|
Pydantic schema generation mode. |
'validation'
|
union_format
|
Literal['any_of', 'primitive_type_array']
|
How to represent unions; ignored on Pydantic versions older than 2.12. |
'any_of'
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
JSON Schema annotated with GKM metadata. |
get_extensions_by_name
get_extensions_by_name(name: str) -> list[Extension]
Fetch all contained extension exactly matching the provided name
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
name of extension to fetch |
required |
Returns:
| Type | Description |
|---|---|
list[Extension]
|
a list of all matching extensions, empty if no matches found (or if instance contains no extensions) |
Entity
Bases: GKMCoreMetadataMixin, BaseModel
Anything that exists, has existed, or will exist.
id
class-attribute
instance-attribute
id: str | None = Field(
default=None,
description="The 'logical' identifier of the Entity in the system of record, e.g. a UUID. This 'id' is unique within a given system, but may or may not be globally unique outside the system. It is used within a system to reference an object from another.",
)
type
class-attribute
instance-attribute
type: str = Field(
...,
description="The name of the class that is instantiated by a data object representing the Entity.",
)
name
class-attribute
instance-attribute
description
class-attribute
instance-attribute
description: str | None = Field(
default=None,
description="A free-text description of the Entity.",
)
aliases
class-attribute
instance-attribute
aliases: list[str] | None = Field(
default=None,
description="Alternative name(s) for the Entity.",
)
extensions
class-attribute
instance-attribute
extensions: list[Extension] | None = Field(
default=None,
description="A list of extensions to the Entity, that allow for capture of information not directly supported by elements defined in the model.",
)
schema_id
classmethod
Return the canonical JSON Schema identifier for the model.
Returns:
| Type | Description |
|---|---|
str
|
Canonical schema URI. |
maturity
classmethod
Return the GKM maturity level for the model.
Returns:
| Type | Description |
|---|---|
Maturity
|
Declared maturity level. |
apply_schema_metadata
classmethod
Add GKM metadata to a generated JSON Schema.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
schema
|
dict[str, Any]
|
Generated JSON Schema to mutate in place. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
The annotated JSON Schema. |
model_json_schema
classmethod
model_json_schema(
by_alias: bool = True,
ref_template: str = "#/$defs/{model}",
schema_generator: type[
GenerateJsonSchema
] = GenerateJsonSchema,
mode: JsonSchemaMode = "validation",
*,
union_format: Literal[
"any_of", "primitive_type_array"
] = "any_of",
) -> dict[str, Any]
Generate JSON Schema with GKM metadata.
Default values follow Pydantic defaults.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
by_alias
|
bool
|
Whether to use field aliases. |
True
|
ref_template
|
str
|
Template for schema references. |
'#/$defs/{model}'
|
schema_generator
|
type[GenerateJsonSchema]
|
Pydantic schema generator class. |
GenerateJsonSchema
|
mode
|
JsonSchemaMode
|
Pydantic schema generation mode. |
'validation'
|
union_format
|
Literal['any_of', 'primitive_type_array']
|
How to represent unions; ignored on Pydantic versions older than 2.12. |
'any_of'
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
JSON Schema annotated with GKM metadata. |
Coding
Bases: Element, BaseModelForbidExtra
A structured representation of a code for a defined concept in a terminology or code system.
name
class-attribute
instance-attribute
name: str | None = Field(
default=None,
description="The human-readable name for the coded concept, as defined by the code system.",
)
system
class-attribute
instance-attribute
system: str = Field(
...,
description="The terminology/code system that defined the code. May be reported as a free-text name (e.g. 'Sequence Ontology'), but it is preferable to provide a uri/url for the system.",
)
systemVersion
class-attribute
instance-attribute
systemVersion: str | None = Field(
default=None,
description="Version of the terminology or code system that provided the code.",
)
iris
class-attribute
instance-attribute
iris: list[iriReference] | None = Field(
default=None,
description="A list of IRIs that are associated with the coding. This can be used to provide additional context or to link to additional information about the concept.",
)
id
class-attribute
instance-attribute
id: str | None = Field(
default=None,
description="The 'logical' identifier of the data element in the system of record, e.g. a UUID. This 'id' is unique within a given system, but may or may not be globally unique outside the system. It is used within a system to reference an object from another.",
)
extensions
class-attribute
instance-attribute
extensions: list[Extension] | None = Field(
default=None,
description="A list of extensions to the Entity, that allow for capture of information not directly supported by elements defined in the model.",
)
schema_id
classmethod
Return the canonical JSON Schema identifier for the model.
Returns:
| Type | Description |
|---|---|
str
|
Canonical schema URI. |
maturity
classmethod
Return the GKM maturity level for the model.
Returns:
| Type | Description |
|---|---|
Maturity
|
Declared maturity level. |
apply_schema_metadata
classmethod
Add GKM metadata to a generated JSON Schema.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
schema
|
dict[str, Any]
|
Generated JSON Schema to mutate in place. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
The annotated JSON Schema. |
model_json_schema
classmethod
model_json_schema(
by_alias: bool = True,
ref_template: str = "#/$defs/{model}",
schema_generator: type[
GenerateJsonSchema
] = GenerateJsonSchema,
mode: JsonSchemaMode = "validation",
*,
union_format: Literal[
"any_of", "primitive_type_array"
] = "any_of",
) -> dict[str, Any]
Generate JSON Schema with GKM metadata.
Default values follow Pydantic defaults.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
by_alias
|
bool
|
Whether to use field aliases. |
True
|
ref_template
|
str
|
Template for schema references. |
'#/$defs/{model}'
|
schema_generator
|
type[GenerateJsonSchema]
|
Pydantic schema generator class. |
GenerateJsonSchema
|
mode
|
JsonSchemaMode
|
Pydantic schema generation mode. |
'validation'
|
union_format
|
Literal['any_of', 'primitive_type_array']
|
How to represent unions; ignored on Pydantic versions older than 2.12. |
'any_of'
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
JSON Schema annotated with GKM metadata. |
get_extensions_by_name
get_extensions_by_name(name: str) -> list[Extension]
Fetch all contained extension exactly matching the provided name
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
name of extension to fetch |
required |
Returns:
| Type | Description |
|---|---|
list[Extension]
|
a list of all matching extensions, empty if no matches found (or if instance contains no extensions) |
ConceptMapping
Bases: Element, BaseModelForbidExtra
A mapping to a concept in a terminology or code system.
coding
class-attribute
instance-attribute
coding: Coding = Field(
...,
description="A structured representation of a code for a defined concept in a terminology or code system.",
)
relation
class-attribute
instance-attribute
relation: Relation = Field(
...,
description="A mapping relation between concepts as defined by the Simple Knowledge Organization System (SKOS).",
)
id
class-attribute
instance-attribute
id: str | None = Field(
default=None,
description="The 'logical' identifier of the data element in the system of record, e.g. a UUID. This 'id' is unique within a given system, but may or may not be globally unique outside the system. It is used within a system to reference an object from another.",
)
extensions
class-attribute
instance-attribute
extensions: list[Extension] | None = Field(
default=None,
description="A list of extensions to the Entity, that allow for capture of information not directly supported by elements defined in the model.",
)
schema_id
classmethod
Return the canonical JSON Schema identifier for the model.
Returns:
| Type | Description |
|---|---|
str
|
Canonical schema URI. |
maturity
classmethod
Return the GKM maturity level for the model.
Returns:
| Type | Description |
|---|---|
Maturity
|
Declared maturity level. |
apply_schema_metadata
classmethod
Add GKM metadata to a generated JSON Schema.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
schema
|
dict[str, Any]
|
Generated JSON Schema to mutate in place. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
The annotated JSON Schema. |
model_json_schema
classmethod
model_json_schema(
by_alias: bool = True,
ref_template: str = "#/$defs/{model}",
schema_generator: type[
GenerateJsonSchema
] = GenerateJsonSchema,
mode: JsonSchemaMode = "validation",
*,
union_format: Literal[
"any_of", "primitive_type_array"
] = "any_of",
) -> dict[str, Any]
Generate JSON Schema with GKM metadata.
Default values follow Pydantic defaults.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
by_alias
|
bool
|
Whether to use field aliases. |
True
|
ref_template
|
str
|
Template for schema references. |
'#/$defs/{model}'
|
schema_generator
|
type[GenerateJsonSchema]
|
Pydantic schema generator class. |
GenerateJsonSchema
|
mode
|
JsonSchemaMode
|
Pydantic schema generation mode. |
'validation'
|
union_format
|
Literal['any_of', 'primitive_type_array']
|
How to represent unions; ignored on Pydantic versions older than 2.12. |
'any_of'
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
JSON Schema annotated with GKM metadata. |
get_extensions_by_name
get_extensions_by_name(name: str) -> list[Extension]
Fetch all contained extension exactly matching the provided name
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
name of extension to fetch |
required |
Returns:
| Type | Description |
|---|---|
list[Extension]
|
a list of all matching extensions, empty if no matches found (or if instance contains no extensions) |
ConceptSet
Bases: Entity, BaseModelForbidExtra
A set of concepts that may be considered as dependent (occurring together), or independent (existing separately) in the context of some knowledge reported about them, as indicated by a set membership operator. e.g. a set of independent molecular consequences that both result from the presence of a particular genetic variant (membership operator = OR).
type
class-attribute
instance-attribute
conceptSetType
class-attribute
instance-attribute
conceptSetType: str | None = Field(
default=None,
description="A term indicating the type of concept being represented by the ConceptSet.",
)
concepts
class-attribute
instance-attribute
concepts: list[
MappableConcept | ConceptSet | iriReference
] = Field(
...,
description="A list of concepts that are dependent (occurring together), or independent (existing separately), depending on the membership operator.",
min_length=2,
)
membershipOperator
class-attribute
instance-attribute
membershipOperator: MembershipOperator = Field(
...,
description="The logical relationship between concepts in the set, in the context of some knowledge reported about them. The value 'AND' indicates that the concepts are dependent and occur together in this context - i.e. the reported assertion is not necessarily true for each concept on its own - only in combination with the other(s). The value 'OR' indicates that each concept applies independently in this context - i.e. the reported assertion is necessarily true for each concept on its own, independent of the presence of the other(s).",
)
id
class-attribute
instance-attribute
id: str | None = Field(
default=None,
description="The 'logical' identifier of the Entity in the system of record, e.g. a UUID. This 'id' is unique within a given system, but may or may not be globally unique outside the system. It is used within a system to reference an object from another.",
)
name
class-attribute
instance-attribute
description
class-attribute
instance-attribute
description: str | None = Field(
default=None,
description="A free-text description of the Entity.",
)
aliases
class-attribute
instance-attribute
aliases: list[str] | None = Field(
default=None,
description="Alternative name(s) for the Entity.",
)
extensions
class-attribute
instance-attribute
extensions: list[Extension] | None = Field(
default=None,
description="A list of extensions to the Entity, that allow for capture of information not directly supported by elements defined in the model.",
)
schema_id
classmethod
Return the canonical JSON Schema identifier for the model.
Returns:
| Type | Description |
|---|---|
str
|
Canonical schema URI. |
maturity
classmethod
Return the GKM maturity level for the model.
Returns:
| Type | Description |
|---|---|
Maturity
|
Declared maturity level. |
apply_schema_metadata
classmethod
Add GKM metadata to a generated JSON Schema.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
schema
|
dict[str, Any]
|
Generated JSON Schema to mutate in place. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
The annotated JSON Schema. |
model_json_schema
classmethod
model_json_schema(
by_alias: bool = True,
ref_template: str = "#/$defs/{model}",
schema_generator: type[
GenerateJsonSchema
] = GenerateJsonSchema,
mode: JsonSchemaMode = "validation",
*,
union_format: Literal[
"any_of", "primitive_type_array"
] = "any_of",
) -> dict[str, Any]
Generate JSON Schema with GKM metadata.
Default values follow Pydantic defaults.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
by_alias
|
bool
|
Whether to use field aliases. |
True
|
ref_template
|
str
|
Template for schema references. |
'#/$defs/{model}'
|
schema_generator
|
type[GenerateJsonSchema]
|
Pydantic schema generator class. |
GenerateJsonSchema
|
mode
|
JsonSchemaMode
|
Pydantic schema generation mode. |
'validation'
|
union_format
|
Literal['any_of', 'primitive_type_array']
|
How to represent unions; ignored on Pydantic versions older than 2.12. |
'any_of'
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
JSON Schema annotated with GKM metadata. |
MappableConcept
Bases: Entity, BaseModelForbidExtra
A concept based on a primaryCoding and/or name that may be mapped to one or more other Codings.
type
class-attribute
instance-attribute
type: Literal["MappableConcept"] = Field(
default="MappableConcept",
description='MUST be "MappableConcept".',
)
conceptType
class-attribute
instance-attribute
conceptType: str | None = Field(
default=None,
description="A term indicating the type of concept being represented by the MappableConcept.",
)
name
class-attribute
instance-attribute
primaryCoding
class-attribute
instance-attribute
primaryCoding: Coding | None = Field(
default=None,
description="A primary coding for the concept.",
)
mappings
class-attribute
instance-attribute
mappings: list[ConceptMapping] | None = Field(
default=None,
description="A list of mappings to concepts in terminologies or code systems. Each mapping should include a coding and a relation.",
)
id
class-attribute
instance-attribute
id: str | None = Field(
default=None,
description="The 'logical' identifier of the Entity in the system of record, e.g. a UUID. This 'id' is unique within a given system, but may or may not be globally unique outside the system. It is used within a system to reference an object from another.",
)
description
class-attribute
instance-attribute
description: str | None = Field(
default=None,
description="A free-text description of the Entity.",
)
aliases
class-attribute
instance-attribute
aliases: list[str] | None = Field(
default=None,
description="Alternative name(s) for the Entity.",
)
extensions
class-attribute
instance-attribute
extensions: list[Extension] | None = Field(
default=None,
description="A list of extensions to the Entity, that allow for capture of information not directly supported by elements defined in the model.",
)
require_name_or_primary_coding
Ensure that name or primaryCoding is provided
Returns:
| Type | Description |
|---|---|
Self
|
Validated object. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If both name and primaryCoding are None. |
schema_id
classmethod
Return the canonical JSON Schema identifier for the model.
Returns:
| Type | Description |
|---|---|
str
|
Canonical schema URI. |
maturity
classmethod
Return the GKM maturity level for the model.
Returns:
| Type | Description |
|---|---|
Maturity
|
Declared maturity level. |
apply_schema_metadata
classmethod
Add GKM metadata to a generated JSON Schema.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
schema
|
dict[str, Any]
|
Generated JSON Schema to mutate in place. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
The annotated JSON Schema. |
model_json_schema
classmethod
model_json_schema(
by_alias: bool = True,
ref_template: str = "#/$defs/{model}",
schema_generator: type[
GenerateJsonSchema
] = GenerateJsonSchema,
mode: JsonSchemaMode = "validation",
*,
union_format: Literal[
"any_of", "primitive_type_array"
] = "any_of",
) -> dict[str, Any]
Generate JSON Schema with GKM metadata.
Default values follow Pydantic defaults.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
by_alias
|
bool
|
Whether to use field aliases. |
True
|
ref_template
|
str
|
Template for schema references. |
'#/$defs/{model}'
|
schema_generator
|
type[GenerateJsonSchema]
|
Pydantic schema generator class. |
GenerateJsonSchema
|
mode
|
JsonSchemaMode
|
Pydantic schema generation mode. |
'validation'
|
union_format
|
Literal['any_of', 'primitive_type_array']
|
How to represent unions; ignored on Pydantic versions older than 2.12. |
'any_of'
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
JSON Schema annotated with GKM metadata. |