From a62e32f510939565b50f8274683f3b5ebc7fe91d Mon Sep 17 00:00:00 2001 From: DeltaDaniel <139119540+DeltaDaniel@users.noreply.github.com> Date: Tue, 18 Jun 2024 09:28:40 +0200 Subject: [PATCH 1/5] add conditions field to AHBLine --- src/maus/models/anwendungshandbuch.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/maus/models/anwendungshandbuch.py b/src/maus/models/anwendungshandbuch.py index 5a7a1c5..46eb900 100644 --- a/src/maus/models/anwendungshandbuch.py +++ b/src/maus/models/anwendungshandbuch.py @@ -83,7 +83,13 @@ class AhbLine: ) """a requirement indicator + an optional condition ("ahb expression"), e.g. 'Muss [123] O [456]' """ # note: to parse expressions from AHBs consider using AHBicht: https://github.com/Hochfrequenz/ahbicht/ - + conditions: Optional[str] = attrs.field( + validator=attrs.validators.optional(validator=attrs.validators.instance_of(str)), default=None + ) + """ + The condition text describes the text to the optional condition of the ahb expression. + E.g. '[492] This is a condition text. [999] And this is another one.' + """ section_name: Optional[str] = attrs.field( validator=attrs.validators.optional(validator=attrs.validators.instance_of(str)), default=None ) From 1034c1e557ca52fb1a7c41994eef467b8d5f2b28 Mon Sep 17 00:00:00 2001 From: DeltaDaniel <139119540+DeltaDaniel@users.noreply.github.com> Date: Tue, 18 Jun 2024 09:38:13 +0200 Subject: [PATCH 2/5] Updated requirements and added ahbicht --- requirements.in | 1 + requirements.txt | 33 ++++++++++++++++++++++++++++----- 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/requirements.in b/requirements.in index dbd30b1..1bb5a8e 100644 --- a/requirements.in +++ b/requirements.in @@ -1,3 +1,4 @@ +ahbicht attrs>=22.1.0 marshmallow lxml>=4.9.2 diff --git a/requirements.txt b/requirements.txt index 0c1f728..d570787 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,22 +1,45 @@ # -# This file is autogenerated by pip-compile with Python 3.11 +# This file is autogenerated by pip-compile with Python 3.12 # by the following command: # # pip-compile requirements.in # -attrs==23.2.0 +ahbicht==0.8.4 # via -r requirements.in +attrs==23.2.0 + # via + # -r requirements.in + # ahbicht + # maus click==8.1.7 # via -r requirements.in +colorama==0.4.6 + # via click +inject==5.2.1 + # via ahbicht lark==1.1.9 - # via -r requirements.in + # via + # -r requirements.in + # ahbicht lxml==5.2.2 # via -r requirements.in marshmallow==3.21.2 - # via -r requirements.in + # via + # -r requirements.in + # ahbicht + # marshmallow-enum + # maus +marshmallow-enum==1.5.1 + # via ahbicht +maus==0.5.0 + # via ahbicht more-itertools==10.2.0 - # via -r requirements.in + # via + # -r requirements.in + # maus packaging==24.0 # via marshmallow +pytz==2024.1 + # via ahbicht xmltodict==0.13.0 # via -r requirements.in From 7009bafbc6eaa8a794f063e64bb9b2de441d8f1b Mon Sep 17 00:00:00 2001 From: DeltaDaniel <139119540+DeltaDaniel@users.noreply.github.com> Date: Tue, 18 Jun 2024 09:57:21 +0200 Subject: [PATCH 3/5] update schema too --- src/maus/models/anwendungshandbuch.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/maus/models/anwendungshandbuch.py b/src/maus/models/anwendungshandbuch.py index 46eb900..f349d0d 100644 --- a/src/maus/models/anwendungshandbuch.py +++ b/src/maus/models/anwendungshandbuch.py @@ -147,6 +147,7 @@ class AhbLineSchema(Schema): value_pool_entry = fields.String(required=False, load_default=None) name = fields.String(required=False, load_default=None) ahb_expression = fields.String(required=False, load_default=None) + conditions = fields.String(required=False, load_default=None) section_name = fields.String(required=False, load_default=None) index = fields.Int(required=False, load_default=None, dump_default=None) From 32119fc03e69b9bbab09388a22605c4d2514c8dc Mon Sep 17 00:00:00 2001 From: DeltaDaniel <139119540+DeltaDaniel@users.noreply.github.com> Date: Tue, 25 Jun 2024 09:35:30 +0200 Subject: [PATCH 4/5] Revert "Updated requirements and added ahbicht" This reverts commit 1034c1e557ca52fb1a7c41994eef467b8d5f2b28. --- requirements.in | 1 - requirements.txt | 33 +++++---------------------------- 2 files changed, 5 insertions(+), 29 deletions(-) diff --git a/requirements.in b/requirements.in index 1bb5a8e..dbd30b1 100644 --- a/requirements.in +++ b/requirements.in @@ -1,4 +1,3 @@ -ahbicht attrs>=22.1.0 marshmallow lxml>=4.9.2 diff --git a/requirements.txt b/requirements.txt index d570787..0c1f728 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,45 +1,22 @@ # -# This file is autogenerated by pip-compile with Python 3.12 +# This file is autogenerated by pip-compile with Python 3.11 # by the following command: # # pip-compile requirements.in # -ahbicht==0.8.4 - # via -r requirements.in attrs==23.2.0 - # via - # -r requirements.in - # ahbicht - # maus + # via -r requirements.in click==8.1.7 # via -r requirements.in -colorama==0.4.6 - # via click -inject==5.2.1 - # via ahbicht lark==1.1.9 - # via - # -r requirements.in - # ahbicht + # via -r requirements.in lxml==5.2.2 # via -r requirements.in marshmallow==3.21.2 - # via - # -r requirements.in - # ahbicht - # marshmallow-enum - # maus -marshmallow-enum==1.5.1 - # via ahbicht -maus==0.5.0 - # via ahbicht + # via -r requirements.in more-itertools==10.2.0 - # via - # -r requirements.in - # maus + # via -r requirements.in packaging==24.0 # via marshmallow -pytz==2024.1 - # via ahbicht xmltodict==0.13.0 # via -r requirements.in From 4f365a85116c99a6e95efbf5a9792efb726d1b09 Mon Sep 17 00:00:00 2001 From: DeltaDaniel <139119540+DeltaDaniel@users.noreply.github.com> Date: Wed, 10 Jul 2024 15:13:08 +0200 Subject: [PATCH 5/5] updated tests --- requirements.txt | 4 +++- tests/unit_tests/test_ahb.py | 12 ++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index fbf260e..96ca10d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ # -# This file is autogenerated by pip-compile with Python 3.11 +# This file is autogenerated by pip-compile with Python 3.12 # by the following command: # # pip-compile requirements.in @@ -8,6 +8,8 @@ attrs==23.2.0 # via -r requirements.in click==8.1.7 # via -r requirements.in +colorama==0.4.6 + # via click lark==1.1.9 # via -r requirements.in lxml==5.2.2 diff --git a/tests/unit_tests/test_ahb.py b/tests/unit_tests/test_ahb.py index 3ee7d1c..6a789f5 100644 --- a/tests/unit_tests/test_ahb.py +++ b/tests/unit_tests/test_ahb.py @@ -28,6 +28,7 @@ line_x = AhbLine( ahb_expression="Muss [1] O [2]", + conditions="[1] Test\n[2] Test", segment_group_key="SG2", segment_code="NAD", data_element="3039", @@ -37,6 +38,7 @@ ) line_y = AhbLine( ahb_expression="Muss [3] O [4]", + conditions="[3] Test\n[4] Test", segment_group_key="SG2", segment_code="NAD", data_element="3039", @@ -86,6 +88,7 @@ def test_ahb_meta_information_equality(self, ahb_x: AhbMetaInformation, ahb_y: A pytest.param( AhbLine( ahb_expression="Muss [1] O [2]", + conditions="[1] Test\n[2] Test", segment_group_key="SG2", segment_code="NAD", segment_id="01234", @@ -105,12 +108,14 @@ def test_ahb_meta_information_equality(self, ahb_x: AhbMetaInformation, ahb_y: A "name": "MP-ID", "guid": "12b1a98a-edf5-4177-89e5-a6d8a92c5fdc", "section_name": "Foo", + "conditions": "[1] Test\n[2] Test", "index": None, }, ), pytest.param( AhbLine( ahb_expression="Muss [1] O [2]", + conditions="[1] Test\n[2] Test", segment_group_key="SG2", segment_code="NAD", segment_id=None, @@ -131,6 +136,7 @@ def test_ahb_meta_information_equality(self, ahb_x: AhbMetaInformation, ahb_y: A "name": "MP-ID", "guid": "12b1a98a-edf5-4177-89e5-a6d8a92c5fdc", "section_name": "Foo", + "conditions": "[1] Test\n[2] Test", "index": 42, }, ), @@ -156,6 +162,7 @@ def test_ahb_line_equality(self, line_x: AhbLine, line_y: AhbLine, are_equal: bo pytest.param( AhbLine( ahb_expression="Muss [1] O [2]", + conditions="[1] Test\n[2] Test", segment_group_key="SG2", segment_code="NAD", data_element="3039", @@ -201,6 +208,7 @@ def test_ahbline_holds_any_information(self, ahb_line: AhbLine, expected_holds_a pytest.param( AhbLine( ahb_expression="Muss [1] O [2]", + conditions="[1] Test\n[2] Test", segment_group_key="SG2", segment_code="NAD", data_element="3039", @@ -214,6 +222,7 @@ def test_ahbline_holds_any_information(self, ahb_line: AhbLine, expected_holds_a pytest.param( AhbLine( ahb_expression="Muss [1] O [2]", + conditions="[1] Test\n[2] Test", segment_group_key="SG2", segment_code="NAD", data_element="3039", @@ -227,6 +236,7 @@ def test_ahbline_holds_any_information(self, ahb_line: AhbLine, expected_holds_a pytest.param( AhbLine( ahb_expression="Muss [1] O [2]", + conditions="[1] Test\n[2] Test", segment_group_key=None, segment_code="UNH", data_element="0062", @@ -252,6 +262,7 @@ def test_ahbline_get_discriminator(self, ahb_line: AhbLine, include_name: bool, lines=[ AhbLine( ahb_expression="Muss [1] O [2]", + conditions="[1] Test\n[2] Test", segment_group_key="SG2", segment_code="NAD", data_element="3039", @@ -280,6 +291,7 @@ def test_ahbline_get_discriminator(self, ahb_line: AhbLine, include_name: bool, "name": "MP-ID", "guid": "12b1a98a-edf5-4177-89e5-a6d8a92c5fdc", "section_name": "MP-ID Absender", + "conditions": "[1] Test\n[2] Test", "index": None, } ],