From cac100d514bb9a659cd550eb05d7568c516c34dc Mon Sep 17 00:00:00 2001 From: frehburg Date: Wed, 18 Sep 2024 11:47:40 +0200 Subject: [PATCH 1/2] wrote pydoc for datafieldvalue --- src/phenopacket_mapper/data_standards/data_model.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/phenopacket_mapper/data_standards/data_model.py b/src/phenopacket_mapper/data_standards/data_model.py index 639a16ea..d44f3462 100644 --- a/src/phenopacket_mapper/data_standards/data_model.py +++ b/src/phenopacket_mapper/data_standards/data_model.py @@ -41,7 +41,13 @@ def __str__(self): @dataclass(slots=True, frozen=True) class DataFieldValue: - """This class defines the value of a `DataField` in a `DataModelInstance`""" + """This class defines the value of a `DataField` in a `DataModelInstance` + + Equivalent to a cell value in a table. + + :ivar field: DataField: The `DataField` to which this value belongs and which defines the value set for the field. + :ivar value: The value of the field. + """ field: DataField value: Union[int, float, str, bool, Date, CodeSystem] From 1d0998c828cd763c63ebfb7a09c1084639b799a4 Mon Sep 17 00:00:00 2001 From: frehburg Date: Wed, 18 Sep 2024 11:47:53 +0200 Subject: [PATCH 2/2] wrote some code for validation of data instances --- .../data_standards/data_model.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/phenopacket_mapper/data_standards/data_model.py b/src/phenopacket_mapper/data_standards/data_model.py index d44f3462..797cd3e0 100644 --- a/src/phenopacket_mapper/data_standards/data_model.py +++ b/src/phenopacket_mapper/data_standards/data_model.py @@ -51,6 +51,17 @@ class DataFieldValue: field: DataField value: Union[int, float, str, bool, Date, CodeSystem] + def validate(self) -> bool: + """Validates the data model instance based on data model definition + + This method checks if the instance is valid based on the data model definition. It checks if all required fields + are present, if the values are in the value set, etc. + + :return: True if the instance is valid, False otherwise + """ + # TODO: Implement this method + raise NotImplementedError + @dataclass(slots=True, frozen=True) class DataModel: @@ -161,5 +172,7 @@ def validate(self) -> bool: :return: True if the instance is valid, False otherwise """ - # TODO: Implement this method - raise NotImplementedError + for v in self.values: + if not v.validate(): + return False + return True