From 66444a5b6da4cd5d571a8cc28a336c697ee921a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jordi=20Puiggen=C3=A9?= Date: Thu, 28 Nov 2024 18:28:05 +0100 Subject: [PATCH 1/5] Compatibility with core#2537 --- src/senaite/ast/config.py | 18 ++++++++---------- src/senaite/ast/setuphandlers.py | 6 ++---- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/src/senaite/ast/config.py b/src/senaite/ast/config.py index 9c9fa6a..ee44219 100644 --- a/src/senaite/ast/config.py +++ b/src/senaite/ast/config.py @@ -114,7 +114,7 @@ u"(Susceptible, increased exposure) and R (Resistant)"), "choices": "0:|1:S|2:I|3:R", "sort_key": 530, - "string_result": True, + "result_type": "string", "point_of_capture": AST_POINT_OF_CAPTURE, "calculation": AST_CALCULATION_TITLE, }, @@ -129,7 +129,7 @@ # XXX This is a choices field, but choices are populated on creation "choices": "", "sort_key": 505, - "string_result": True, + "result_type": "string", "point_of_capture": AST_POINT_OF_CAPTURE, "calculation": AST_CALCULATION_TITLE, }, @@ -144,7 +144,7 @@ u"disk charge."), "size": "3", "sort_key": 510, - "string_result": True, + "result_type": "string", "point_of_capture": AST_POINT_OF_CAPTURE, "calculation": AST_CALCULATION_TITLE, }, @@ -160,7 +160,7 @@ u"susceptible to an antibiotic."), "size": "3", "sort_key": 520, - "string_result": True, + "result_type": "string", "point_of_capture": AST_POINT_OF_CAPTURE, "calculation": AST_CALCULATION_TITLE, }, @@ -176,7 +176,7 @@ u"susceptible to an antibiotic."), "size": "5", "sort_key": 520, - "string_result": True, + "result_type": "string", "point_of_capture": AST_POINT_OF_CAPTURE, "calculation": AST_CALCULATION_TITLE, }, @@ -187,7 +187,7 @@ # XXX senaite.app.listing has no support for boolean types (interim) "type": "boolean", "sort_key": 540, - "string_result": True, + "result_type": "string", "point_of_capture": AST_POINT_OF_CAPTURE, "calculation": AST_CALCULATION_TITLE, }, @@ -200,9 +200,8 @@ u"representatives"), # XXX This is a choices field, but choices are populated on creation "choices": "", - "type": "multichoice", + "result_type": "multichoice", "sort_key": 550, - "string_result": True, "point_of_capture": AST_POINT_OF_CAPTURE, "calculation": AST_CALCULATION_TITLE, }, @@ -212,8 +211,7 @@ "sort_key": 500, # The options are the list of microorganisms and are automatically # added when the corresponding analysis is initialized - "options_type": "multiselect", - "string_result": False, + "result_type": "multiselect", "point_of_capture": "lab", "calculation": None, } diff --git a/src/senaite/ast/setuphandlers.py b/src/senaite/ast/setuphandlers.py index ab4f224..a12936a 100644 --- a/src/senaite/ast/setuphandlers.py +++ b/src/senaite/ast/setuphandlers.py @@ -227,8 +227,7 @@ def setup_ast_services(portal, update_existing=True): description = settings.get("description", AUTOGENERATED) sort_key = settings.get("sort_key", 1000) - options_type = settings.get("options_type", "select") - string_result = settings.get("string_result", False) + result_type = settings.get("result_type", "numeric") poc = settings.get("point_of_capture", AST_POINT_OF_CAPTURE) calc_name = settings.get("calculation", AST_CALCULATION_TITLE) @@ -236,8 +235,7 @@ def setup_ast_services(portal, update_existing=True): service.setTitle(title) service.setDescription(description) service.setSortKey(sort_key) - service.setResultOptionsType(options_type) - service.setStringResult(string_result) + service.setResultType(result_type) service.setPointOfCapture(poc) # Get the calculation From 070abefc131a274138e12c3ff2c0b6ed2880a384 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jordi=20Puiggen=C3=A9?= Date: Thu, 28 Nov 2024 18:33:59 +0100 Subject: [PATCH 2/5] Apply correct result types for AST-like services --- src/senaite/ast/config.py | 6 +++--- src/senaite/ast/setuphandlers.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/senaite/ast/config.py b/src/senaite/ast/config.py index ee44219..2667060 100644 --- a/src/senaite/ast/config.py +++ b/src/senaite/ast/config.py @@ -114,7 +114,7 @@ u"(Susceptible, increased exposure) and R (Resistant)"), "choices": "0:|1:S|2:I|3:R", "sort_key": 530, - "result_type": "string", + "result_type": "select", "point_of_capture": AST_POINT_OF_CAPTURE, "calculation": AST_CALCULATION_TITLE, }, @@ -129,7 +129,7 @@ # XXX This is a choices field, but choices are populated on creation "choices": "", "sort_key": 505, - "result_type": "string", + "result_type": "select", "point_of_capture": AST_POINT_OF_CAPTURE, "calculation": AST_CALCULATION_TITLE, }, @@ -187,7 +187,7 @@ # XXX senaite.app.listing has no support for boolean types (interim) "type": "boolean", "sort_key": 540, - "result_type": "string", + "result_type": "select", "point_of_capture": AST_POINT_OF_CAPTURE, "calculation": AST_CALCULATION_TITLE, }, diff --git a/src/senaite/ast/setuphandlers.py b/src/senaite/ast/setuphandlers.py index a12936a..b80b425 100644 --- a/src/senaite/ast/setuphandlers.py +++ b/src/senaite/ast/setuphandlers.py @@ -227,7 +227,7 @@ def setup_ast_services(portal, update_existing=True): description = settings.get("description", AUTOGENERATED) sort_key = settings.get("sort_key", 1000) - result_type = settings.get("result_type", "numeric") + result_type = settings.get("result_type", "select") poc = settings.get("point_of_capture", AST_POINT_OF_CAPTURE) calc_name = settings.get("calculation", AST_CALCULATION_TITLE) From eb5df89c4ee0cdf2da97594fb491bab77a311164 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jordi=20Puiggen=C3=A9?= Date: Thu, 28 Nov 2024 18:36:33 +0100 Subject: [PATCH 3/5] setResultOptionsType --> setResultType --- src/senaite/ast/workflow/analysis.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/senaite/ast/workflow/analysis.py b/src/senaite/ast/workflow/analysis.py index facc695..6ea654e 100644 --- a/src/senaite/ast/workflow/analysis.py +++ b/src/senaite/ast/workflow/analysis.py @@ -46,7 +46,7 @@ def after_initialize(analysis): options = zip(range(len(names)), names) options = map(lambda m: {"ResultValue": m[0], "ResultText": m[1]}, options) analysis.setResultOptions(options) - analysis.setResultOptionsType("multiselect") + analysis.setResultType("multiselect") analysis.reindexObject() From 62573b461b58a9a5709fdb4b3873bb64384519c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jordi=20Puiggen=C3=A9?= Date: Thu, 28 Nov 2024 18:37:39 +0100 Subject: [PATCH 4/5] Changelog --- docs/changelog.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/changelog.rst b/docs/changelog.rst index 2e48f6c..061bb8e 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -4,6 +4,7 @@ Changelog 1.2.0 (unreleased) ------------------ +- #40 Compatibility with core#2537 (Support multi-text on result entry) - #39 Compatibility with core#2584 (SampleType to DX) - #38 Compatibility with core#2595 (Move ARAnalysesField logic to data manager) - #37 Compatibility with core#2567 (AnalysisCategory to DX) From dc0773ce7b7ad46c3b206ada11a7e377d2c1ec90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jordi=20Puiggen=C3=A9?= Date: Thu, 28 Nov 2024 18:45:15 +0100 Subject: [PATCH 5/5] Added upgrade step --- src/senaite/ast/profiles/default/metadata.xml | 2 +- src/senaite/ast/upgrade/v01_02_000.py | 34 +++++++++++++++++++ src/senaite/ast/upgrade/v01_02_000.zcml | 8 +++++ 3 files changed, 43 insertions(+), 1 deletion(-) diff --git a/src/senaite/ast/profiles/default/metadata.xml b/src/senaite/ast/profiles/default/metadata.xml index 2bc3e64..e5c2285 100644 --- a/src/senaite/ast/profiles/default/metadata.xml +++ b/src/senaite/ast/profiles/default/metadata.xml @@ -6,7 +6,7 @@ dependencies before installing this add-on own profile. --> - 1202 + 1203 diff --git a/src/senaite/ast/upgrade/v01_02_000.py b/src/senaite/ast/upgrade/v01_02_000.py index 547470f..3fcee36 100644 --- a/src/senaite/ast/upgrade/v01_02_000.py +++ b/src/senaite/ast/upgrade/v01_02_000.py @@ -22,9 +22,11 @@ from senaite.ast import logger from senaite.ast import PRODUCT_NAME from senaite.ast.config import AST_POINT_OF_CAPTURE +from senaite.ast.config import SERVICES_SETTINGS from senaite.ast.setuphandlers import revoke_edition_permissions from senaite.ast.setuphandlers import setup_workflows from senaite.core.catalog import ANALYSIS_CATALOG +from senaite.core.catalog import SETUP_CATALOG from senaite.core.upgrade import upgradestep from senaite.core.upgrade.utils import UpgradeUtils @@ -91,3 +93,35 @@ def update_role_mappings_for(object_or_brain): def revoke_setup_permissions(tool): portal = tool.aq_inner.aq_parent revoke_edition_permissions(portal) + + +def restore_ast_result_type(tool): + """Setup analysis/service result types + """ + logger.info("Restore ResultType from AST-like services ...") + # analysis services + query = { + "portal_type": "AnalysisService", + "point_of_capture": AST_POINT_OF_CAPTURE + } + brains = api.search(query, SETUP_CATALOG) + total = len(brains) + for num, brain in enumerate(brains): + + if num and num % 1000 == 0: + logger.info("Setup result types %s/%s" % (num, total)) + + obj = api.get_object(brain) + if not obj: + continue + + keyword = obj.getKeyword() + settings = SERVICES_SETTINGS.get(keyword) + if not settings: + continue + + result_type = settings.get("result_type") + obj.setResultType(result_type) + obj._p_deactivate() + + logger.info("Restore ResultType from AST-like services [DONE]") diff --git a/src/senaite/ast/upgrade/v01_02_000.zcml b/src/senaite/ast/upgrade/v01_02_000.zcml index b63486f..4acb82c 100644 --- a/src/senaite/ast/upgrade/v01_02_000.zcml +++ b/src/senaite/ast/upgrade/v01_02_000.zcml @@ -2,6 +2,14 @@ xmlns="http://namespaces.zope.org/zope" xmlns:genericsetup="http://namespaces.zope.org/genericsetup"> + +