Skip to content

Commit 9e781d8

Browse files
🔨 Move "concept" information out
1 parent e3d3005 commit 9e781d8

File tree

3 files changed

+73
-25
lines changed

3 files changed

+73
-25
lines changed

‎src/include_access_model/datamodel/include_access_model.py‎

Lines changed: 41 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Auto generated from include_access_model.yaml by pythongen.py version: 0.0.1
2-
# Generation date: 2025-11-11T16:08:56
2+
# Generation date: 2025-11-12T07:19:24
33
# Schema: include-access-model
44
#
55
# id: https://includedcc.org/include-access-model
@@ -105,6 +105,10 @@ class SubjectAssertionAssertionId(extended_str):
105105
pass
106106

107107

108+
class ConceptCode(URIorCURIE):
109+
pass
110+
111+
108112
@dataclass(repr=False)
109113
class Record(YAMLRoot):
110114
"""
@@ -515,11 +519,9 @@ class SubjectAssertion(Record):
515519
age_at_assertion: Optional[int] = None
516520
age_at_event: Optional[int] = None
517521
age_at_resolution: Optional[int] = None
518-
code: Optional[Union[str, URIorCURIE]] = None
519-
display: Optional[str] = None
522+
code: Optional[Union[Union[str, URIorCURIE], list[Union[str, URIorCURIE]]]] = empty_list()
520523
code_source: Optional[str] = None
521524
value_code: Optional[Union[str, URIorCURIE]] = None
522-
value_display: Optional[str] = None
523525
value_number: Optional[float] = None
524526
value_source: Optional[str] = None
525527
value_units: Optional[Union[str, URIorCURIE]] = None
@@ -547,21 +549,16 @@ def __post_init__(self, *_: str, **kwargs: Any):
547549
if self.age_at_resolution is not None and not isinstance(self.age_at_resolution, int):
548550
self.age_at_resolution = int(self.age_at_resolution)
549551

550-
if self.code is not None and not isinstance(self.code, URIorCURIE):
551-
self.code = URIorCURIE(self.code)
552-
553-
if self.display is not None and not isinstance(self.display, str):
554-
self.display = str(self.display)
552+
if not isinstance(self.code, list):
553+
self.code = [self.code] if self.code is not None else []
554+
self.code = [v if isinstance(v, URIorCURIE) else URIorCURIE(v) for v in self.code]
555555

556556
if self.code_source is not None and not isinstance(self.code_source, str):
557557
self.code_source = str(self.code_source)
558558

559559
if self.value_code is not None and not isinstance(self.value_code, URIorCURIE):
560560
self.value_code = URIorCURIE(self.value_code)
561561

562-
if self.value_display is not None and not isinstance(self.value_display, str):
563-
self.value_display = str(self.value_display)
564-
565562
if self.value_number is not None and not isinstance(self.value_number, float):
566563
self.value_number = float(self.value_number)
567564

@@ -580,6 +577,34 @@ def __post_init__(self, *_: str, **kwargs: Any):
580577
super().__post_init__(**kwargs)
581578

582579

580+
@dataclass(repr=False)
581+
class Concept(YAMLRoot):
582+
"""
583+
A standardized concept with display information.
584+
"""
585+
_inherited_slots: ClassVar[list[str]] = []
586+
587+
class_class_uri: ClassVar[URIRef] = INCLUDEDCC["Concept"]
588+
class_class_curie: ClassVar[str] = "includedcc:Concept"
589+
class_name: ClassVar[str] = "Concept"
590+
class_model_uri: ClassVar[URIRef] = INCLUDEDCC.Concept
591+
592+
code: Union[Union[str, ConceptCode], list[Union[str, ConceptCode]]] = None
593+
display: Optional[str] = None
594+
595+
def __post_init__(self, *_: str, **kwargs: Any):
596+
if self._is_empty(self.code):
597+
self.MissingRequiredField("code")
598+
if not isinstance(self.code, list):
599+
self.code = [self.code] if self.code is not None else []
600+
self.code = [v if isinstance(v, ConceptCode) else ConceptCode(v) for v in self.code]
601+
602+
if self.display is not None and not isinstance(self.display, str):
603+
self.display = str(self.display)
604+
605+
super().__post_init__(**kwargs)
606+
607+
583608
# Enumerations
584609
class EnumProgram(EnumDefinitionImpl):
585610
"""
@@ -1168,7 +1193,7 @@ class slots:
11681193
model_uri=INCLUDEDCC.age_at_resolution, domain=None, range=Optional[int])
11691194

11701195
slots.code = Slot(uri=INCLUDEDCC.code, name="code", curie=INCLUDEDCC.curie('code'),
1171-
model_uri=INCLUDEDCC.code, domain=None, range=Optional[Union[str, URIorCURIE]])
1196+
model_uri=INCLUDEDCC.code, domain=None, range=Optional[Union[Union[str, URIorCURIE], list[Union[str, URIorCURIE]]]])
11721197

11731198
slots.display = Slot(uri=INCLUDEDCC.display, name="display", curie=INCLUDEDCC.curie('display'),
11741199
model_uri=INCLUDEDCC.display, domain=None, range=Optional[str])
@@ -1179,9 +1204,6 @@ class slots:
11791204
slots.value_code = Slot(uri=INCLUDEDCC.value_code, name="value_code", curie=INCLUDEDCC.curie('value_code'),
11801205
model_uri=INCLUDEDCC.value_code, domain=None, range=Optional[Union[str, URIorCURIE]])
11811206

1182-
slots.value_display = Slot(uri=INCLUDEDCC.value_display, name="value_display", curie=INCLUDEDCC.curie('value_display'),
1183-
model_uri=INCLUDEDCC.value_display, domain=None, range=Optional[str])
1184-
11851207
slots.value_number = Slot(uri=INCLUDEDCC.value_number, name="value_number", curie=INCLUDEDCC.curie('value_number'),
11861208
model_uri=INCLUDEDCC.value_number, domain=None, range=Optional[float])
11871209

@@ -1211,3 +1233,6 @@ class slots:
12111233

12121234
slots.SubjectAssertion_assertion_id = Slot(uri=INCLUDEDCC.assertion_id, name="SubjectAssertion_assertion_id", curie=INCLUDEDCC.curie('assertion_id'),
12131235
model_uri=INCLUDEDCC.SubjectAssertion_assertion_id, domain=SubjectAssertion, range=Union[str, SubjectAssertionAssertionId])
1236+
1237+
slots.Concept_code = Slot(uri=INCLUDEDCC.code, name="Concept_code", curie=INCLUDEDCC.curie('code'),
1238+
model_uri=INCLUDEDCC.Concept_code, domain=Concept, range=Union[Union[str, ConceptCode], list[Union[str, ConceptCode]]])

‎src/include_access_model/datamodel/include_access_model_pydantic.py‎

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -515,11 +515,9 @@ class SubjectAssertion(Record):
515515
age_at_assertion: Optional[int] = Field(default=None, title="Age at assertion", description="""The age in days of the Subject when the assertion was made.""", json_schema_extra = { "linkml_meta": {'domain_of': ['SubjectAssertion'], 'unit': {'ucum_code': 'd'}} })
516516
age_at_event: Optional[int] = Field(default=None, title="Age at event", description="""The age in days of the Subject at the time point which the assertion describes, | eg, age of onset or when a measurement was performed.""", json_schema_extra = { "linkml_meta": {'domain_of': ['SubjectAssertion'], 'unit': {'ucum_code': 'd'}} })
517517
age_at_resolution: Optional[int] = Field(default=None, title="Age at resolution", description="""The age in days of the Subject when the asserted state was resolved.""", json_schema_extra = { "linkml_meta": {'domain_of': ['SubjectAssertion'], 'unit': {'ucum_code': 'd'}} })
518-
code: Optional[str] = Field(default=None, title="Assertion Code", description="""The structured term defining the meaning of the assertion.""", json_schema_extra = { "linkml_meta": {'domain_of': ['SubjectAssertion']} })
519-
display: Optional[str] = Field(default=None, title="Display String", description="""The friendly display string of the coded term.""", json_schema_extra = { "linkml_meta": {'domain_of': ['SubjectAssertion']} })
518+
code: Optional[list[str]] = Field(default=[], title="Assertion Code", description="""The structured term defining the meaning of the assertion.""", json_schema_extra = { "linkml_meta": {'domain_of': ['SubjectAssertion', 'Concept']} })
520519
code_source: Optional[str] = Field(default=None, title="Code Source Text", description="""The source text yielding the code.""", json_schema_extra = { "linkml_meta": {'domain_of': ['SubjectAssertion']} })
521520
value_code: Optional[str] = Field(default=None, title="Value Code", description="""The structured term defining the value of the assertion.""", json_schema_extra = { "linkml_meta": {'domain_of': ['SubjectAssertion']} })
522-
value_display: Optional[str] = Field(default=None, title="Value Display String", description="""The friendly display string of the coded term for the value of the assertion.""", json_schema_extra = { "linkml_meta": {'domain_of': ['SubjectAssertion']} })
523521
value_number: Optional[float] = Field(default=None, title="Value Number", description="""The numeric value of the assertion.""", json_schema_extra = { "linkml_meta": {'domain_of': ['SubjectAssertion']} })
524522
value_source: Optional[str] = Field(default=None, title="Value Source Text", description="""The source text yielding the value.""", json_schema_extra = { "linkml_meta": {'domain_of': ['SubjectAssertion']} })
525523
value_units: Optional[str] = Field(default=None, title="Value Units", description="""The structured term defining the units of the value.""", json_schema_extra = { "linkml_meta": {'domain_of': ['SubjectAssertion']} })
@@ -528,6 +526,21 @@ class SubjectAssertion(Record):
528526
external_id: Optional[list[str]] = Field(default=[], title="External Identifiers", description="""Other identifiers for this entity, eg, from the submitting study or in systems like dbGaP""", json_schema_extra = { "linkml_meta": {'domain_of': ['Record']} })
529527

530528

529+
class Concept(ConfiguredBaseModel):
530+
"""
531+
A standardized concept with display information.
532+
"""
533+
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({'from_schema': 'https://includedcc.org/include-access-model',
534+
'slot_usage': {'code': {'identifier': True,
535+
'multivalued': False,
536+
'name': 'code',
537+
'required': True}},
538+
'title': 'Concept'})
539+
540+
code: str = Field(default=..., title="Assertion Code", description="""The structured term defining the meaning of the assertion.""", json_schema_extra = { "linkml_meta": {'domain_of': ['SubjectAssertion', 'Concept']} })
541+
display: Optional[str] = Field(default=None, title="Display String", description="""The friendly display string of the coded term.""", json_schema_extra = { "linkml_meta": {'domain_of': ['Concept']} })
542+
543+
531544
# Model rebuild
532545
# see https://pydantic-docs.helpmanual.io/usage/models/#rebuilding-a-model
533546
Record.model_rebuild()
@@ -539,3 +552,4 @@ class SubjectAssertion(Record):
539552
Subject.model_rebuild()
540553
Demographics.model_rebuild()
541554
SubjectAssertion.model_rebuild()
555+
Concept.model_rebuild()

‎src/include_access_model/schema/include_access_model.yaml‎

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -162,10 +162,11 @@ classes:
162162
- age_at_event
163163
- age_at_resolution
164164
- code
165-
- display
165+
# Moved the displays into the concept
166+
# - display
166167
- code_source
167168
- value_code
168-
- value_display
169+
# - value_display
169170
- value_number
170171
- value_source
171172
- value_units
@@ -175,6 +176,17 @@ classes:
175176
assertion_id:
176177
required: true
177178
identifier: true
179+
Concept:
180+
title: Concept
181+
description: A standardized concept with display information.
182+
slots:
183+
- code
184+
- display
185+
slot_usage:
186+
code:
187+
multivalued: false
188+
required: true
189+
identifier: true
178190

179191
slots:
180192
uuid:
@@ -444,6 +456,7 @@ slots:
444456
title: Assertion Code
445457
description: The structured term defining the meaning of the assertion.
446458
range: uriorcurie
459+
multivalued: true
447460
display:
448461
title: Display String
449462
description: The friendly display string of the coded term.
@@ -456,10 +469,6 @@ slots:
456469
title: Value Code
457470
description: The structured term defining the value of the assertion.
458471
range: uriorcurie
459-
value_display:
460-
title: Value Display String
461-
description: The friendly display string of the coded term for the value of the assertion.
462-
range: string
463472
value_number:
464473
title: Value Number
465474
description: The numeric value of the assertion.

0 commit comments

Comments
 (0)